Contao\Image::getCacheName PHP Method

getCacheName() public method

Get the cache name
public getCacheName ( ) : string
return string The cache name
    public function getCacheName()
    {
        $importantPart = $this->getImportantPart();
        $strCacheKey = substr(md5('-w' . $this->getTargetWidth() . '-h' . $this->getTargetHeight() . '-o' . $this->getOriginalPath() . '-m' . $this->getResizeMode() . '-z' . $this->getZoomLevel() . '-x' . $importantPart['x'] . '-y' . $importantPart['y'] . '-i' . $importantPart['width'] . '-e' . $importantPart['height'] . '-t' . $this->fileObj->mtime), 0, 8);
        return System::getContainer()->getParameter('contao.image.target_path') . '/' . substr($strCacheKey, -1) . '/' . $this->fileObj->filename . '-' . $strCacheKey . '.' . $this->fileObj->extension;
    }

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  */
 public function getCacheName()
 {
     $strFallbackFormat = \Config::get('magickimages_fallback_extension') ?: 'jpg';
     if (!in_array($this->fileObj->extension, ['jpg', 'png', 'gif'])) {
         // Change file suffix
         return substr(parent::getCacheName(), 0, -strlen($this->fileObj->extension)) . $strFallbackFormat;
     }
     return parent::getCacheName();
 }
All Usage Examples Of Contao\Image::getCacheName