Back to PhocacartImage class

Method getThumbnailName

public static
getThumbnailName
(mixed $path, mixed $filename, mixed $size)

Method getThumbnailName - Source code

public static function getThumbnailName($path, $filename, $size)
{
    $paramsC = PhocacartUtils::getComponentParameters();
    $thumb_name_prefix = $paramsC->get('thumb_name_prefix', 'phoca_thumb');
    $thumbName = new StdClass();
    if ($filename == '') {
        $thumbName->abs = false;
        $thumbName->rel = false;
        $thumbName->rel_webp = false;
        return $thumbName;
    }
    $title = self::getTitleFromFile($filename, 1);
    switch ($size) {
        case 'large':
            $fileNameThumb = $thumb_name_prefix . '_l_' . $title;
            $thumbName->abs = Path::clean(str_replace($title, 'thumbs/' . $fileNameThumb, $path['orig_abs_ds'] . $filename));
            $thumbName->rel = str_replace($title, 'thumbs/' . $fileNameThumb, $path['orig_rel_ds'] . $filename);
            $thumbName->rel_webp = PhocacartFile::changeFileExtension($thumbName->rel, 'webp');
            break;
        case 'medium':
            $fileNameThumb = $thumb_name_prefix . '_m_' . $title;
            $thumbName->abs = Path::clean(str_replace($title, 'thumbs/' . $fileNameThumb, $path['orig_abs_ds'] . $filename));
            $thumbName->rel = str_replace($title, 'thumbs/' . $fileNameThumb, $path['orig_rel_ds'] . $filename);
            $thumbName->rel_webp = PhocacartFile::changeFileExtension($thumbName->rel, 'webp');
            break;
        default:
        case 'small':
            $fileNameThumb = $thumb_name_prefix . '_s_' . $title;
            $thumbName->abs = Path::clean(str_replace($title, 'thumbs/' . $fileNameThumb, $path['orig_abs_ds'] . $filename));
            $thumbName->rel = str_replace($title, 'thumbs/' . $fileNameThumb, $path['orig_rel_ds'] . $filename);
            $thumbName->rel_webp = PhocacartFile::changeFileExtension($thumbName->rel, 'webp');
            break;
    }
    return $thumbName;
}