Example #1
0
 public function getTag($width = null, $height = null, $crop = true)
 {
     $tag = new ImageTag($this->image, $this->fileStorage);
     if ($width) {
         $tag->setWidth($width);
     }
     if ($height) {
         $tag->setHeight($height);
     }
     $tag->setCrop($crop);
     return $tag;
 }
Example #2
0
 public function filter($content, array $options = array())
 {
     if ($this->blockProperty->getMetadata()->offsetExists('image')) {
         $element = $this->blockProperty->getMetadata()->get('image')->getReferencedElement();
         if ($element !== null) {
             /* @var $element ImageReferencedElement */
             if (!$element instanceof ImageReferencedElement) {
                 // @TODO: any exception should be thrown probably
                 return null;
             }
             $imageId = $element->getImageId();
             $fileStorage = $this->container['cms.file_storage'];
             /* @var $fileStorage \Supra\Package\Cms\FileStorage\FileStorage */
             $image = $fileStorage->findImage($imageId);
             if ($image) {
                 $tag = new ImageTag($image, $fileStorage);
                 $tag->setAttribute('alt', $element->getAlternateText());
                 return $tag;
             }
         }
     }
     return null;
 }