ImageManager::getThumbnail PHP Метод

getThumbnail() публичный Метод

If the thumbnail exists, and it is up-to-date the thumbnail url will be returns. If the file is not an image, a default image will be returned. If it is an image file, and no thumbnail exists or the thumbnail is out-of-date (i.e. the thumbnail modified time is less than the original file) then a thumbs.php?img=filename.jpg is returned. The thumbs.php url will generate a new thumbnail on the fly. If the image is less than the dimensions of the thumbnails, the image will be display instead.
public getThumbnail ( string $relative ) : string
$relative string the relative image file.
Результат string the url of the thumbnail, be it actually thumbnail or a script to generate the thumbnail on the fly.
    function getThumbnail($relative)
    {
        $fullpath = Files::makeFile($this->getBaseDir(), $relative);
        //not a file???
        if (!is_file($fullpath)) {
            return $this->getDefaultThumb();
        }
        $imgInfo = @getImageSize($fullpath);
        //not an image
        if (!is_array($imgInfo)) {
            return $this->getDefaultThumb();
        }
        //the original image is smaller than thumbnails,
        //so just return the url to the original image.
        if ($imgInfo[0] <= $this->config['thumbnail_width'] && $imgInfo[1] <= $this->config['thumbnail_height']) {
            return $this->getFileURL($relative);
        }
        $thumbnail = $this->getThumbName($fullpath);
        //check for thumbnails, if exists and
        // it is up-to-date, return the thumbnail url
        if (is_file($thumbnail)) {
            if (filemtime($thumbnail) >= filemtime($fullpath)) {
                return $this->getThumbURL($relative);
            }
        }
        //well, no thumbnail was found, so ask the thumbs.php
        //to generate the thumbnail on the fly.
        return 'thumbs.php?img=' . rawurlencode($relative);
    }