private function getRandomImage($type, $placeholder)
    {
        $pathKey = $type === 'image' ? 'file' : 'filename';

        if ($placeholder && ($filename = $this->fetchPlaceholder($placeholder))) {
            return [$pathKey => $filename, 'title' => 'placeholder', 'alt' => 'placeholder'];
        }

        $images = $this->getImageFiles();
        if (empty($images)) {
            return null;
        }
        $imageName = array_rand($images);
        $image = $images[$imageName];
        $title = $image->getFilename($image->getExtension());
        $title = ucwords(str_replace('-', ' ', $title));

        return [$pathKey => $image->getPath(), 'title' => $title, 'alt' => $title];
    }
private function getRandomImage($type, $placeholder)
    {
        $pathKey = $type === 'image' ? 'file' : 'filename';

        if ($placeholder && ($filename = $this->fetchPlaceholder($placeholder))) {
            return [$pathKey => $filename, 'title' => 'placeholder', 'alt' => 'placeholder'];
        }

        $images = $this->getImageFiles();
        if (empty($images)) {
            return null;
        }
        $imageName = array_rand($images);
        $image = $images[$imageName];
        $title = $image->getFilename($image->getExtension());
        $title = ucwords(str_replace('-', ' ', $title));

        return [$pathKey => $image->getPath(), 'title' => $title, 'alt' => $title];
    }
private function getRandomImage ( $ type , $ placeholder ) { $ pathKey = $ type === 'image' ? 'file' : 'filename' ; if ( $ placeholder && ( $ filename = $ this -> fetchPlaceholder ( $ placeholder ) ) ) { return [ $ pathKey => $ filename , 'title' => 'placeholder' , 'alt' => 'placeholder' ] ; } $ images = $ this -> getImageFiles ( ) ; if ( empty ( $ images ) ) { return null ; } $ imageName = array_rand ( $ images ) ; $ image = $ images [ $ imageName ] ; $ title = $ image -> getFilename ( $ image -> getExtension ( ) ) ; $ title = ucwords ( str_replace ( '-' , ' ' , $ title ) ) ; return [ $ pathKey => $ image -> getPath ( ) , 'title' => $ title , 'alt' => $ title ] ; }
Get a random image.

@param string      $type
@param string|null $placeholder

@return array|null
Get a random image .