ImageManager::getDefaultThumb PHP Метод

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

Get the default thumbnail.
public getDefaultThumb ( ) : string
Результат string default thumbnail, empty string if the thumbnail doesn't exist.
    function getDefaultThumb()
    {
        if (is_file($this->config['default_thumbnail'])) {
            return $this->config['default_thumbnail'];
        } else {
            return '';
        }
    }

Usage Example

Пример #1
0
if (!isset($_GET['img'])) {
    exit;
}
$manager = new ImageManager($IMConfig);
//get the image and the full path to the image
$image = rawurldecode($_GET['img']);
$fullpath = Files::makeFile($manager->getBaseDir(), $image);
//not a file, so exit
if (!is_file($fullpath)) {
    exit;
}
$imgInfo = @getImageSize($fullpath);
//Not an image, send default thumbnail
if (!is_array($imgInfo)) {
    //show the default image, otherwise we quit!
    $default = $manager->getDefaultThumb();
    if ($default) {
        header('Location: ' . $default);
        exit;
    }
}
//if the image is less than the thumbnail dimensions
//send the original image as thumbnail
if ($imgInfo[0] <= $IMConfig['thumbnail_width'] && $imgInfo[1] <= $IMConfig['thumbnail_height']) {
    header('Location: ' . $manager->getFileURL($image));
    exit;
}
//Check for thumbnails
$thumbnail = $manager->getThumbName($fullpath);
if (is_file($thumbnail)) {
    //if the thumbnail is newer, send it