Exemple #1
0
 /**
  * Get the URL to the thumbnail file.
  *
  * @param string $type
  * @param Media $media
  * @return string
  */
 public function getThumbnailUrl($type, Media $media)
 {
     if (!$media->hasThumbnails() || !$this->thumbnailTypeExists($type)) {
         $fallbacks = $this->config['thumbnail_fallbacks']['fallbacks'];
         $mediaType = $media->getMediaType();
         $topLevelType = strstr($mediaType, '/', true);
         if (isset($fallbacks[$mediaType])) {
             // Prioritize a match against the full media type, e.g. "image/jpeg"
             $fallback = $fallbacks[$mediaType];
         } elseif ($topLevelType && isset($fallbacks[$topLevelType])) {
             // Then fall back on a match against the top-level type, e.g. "image"
             $fallback = $fallbacks[$topLevelType];
         } else {
             $fallback = $this->config['thumbnail_fallbacks']['default'];
         }
         $assetUrl = $this->getServiceLocator()->get('ViewHelperManager')->get('assetUrl');
         return $assetUrl($fallback[0], $fallback[1]);
     }
     $storagePath = $this->getStoragePath($type, $this->getBasename($media->getFilename()), self::THUMBNAIL_EXTENSION);
     return $this->getStore()->getUri($storagePath);
 }
 /**
  * {@inheritDoc}
  */
 public function hasThumbnails()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'hasThumbnails', array());
     return parent::hasThumbnails();
 }