addImageToTemplate() public static method

Add an image to a template
public static addImageToTemplate ( object $objTemplate, array $arrItem, integer $intMaxWidth = null, string $strLightboxId = null )
$objTemplate object The template object to add the image to
$arrItem array The element or module as array
$intMaxWidth integer An optional maximum width of the image
$strLightboxId string An optional lightbox ID
Esempio n. 1
0
 /**
  * Add an image to a template
  *
  * @param object  $objTemplate   The template object to add the image to
  * @param array   $arrItem       The element or module as array
  * @param integer $intMaxWidth   An optional maximum width of the image
  * @param string  $strLightboxId An optional lightbox ID
  */
 public static function addImageToTemplate($objTemplate, $arrItem, $intMaxWidth = null, $strLightboxId = null)
 {
     if (stristr($arrItem['singleSRC'], '.svg') !== FALSE) {
         $size = deserialize($arrItem['size']);
         $size = self::_getSvgSize($arrItem['singleSRC'], $size);
         $arrItem['size'] = serialize($size);
         @parent::addImageToTemplate($objTemplate, $arrItem, $intMaxWidth, $strLightboxId);
         $imgSize = '';
         $imgSize .= ' width="' . $size[0] . '"';
         $imgSize .= ' height="' . $size[1] . '"';
         $objTemplate->imgSize = $imgSize;
         $objTemplate->svgImage = TRUE;
         if ($width > 0 && $height > 0) {
             $objTemplate->width = $imgSize[0];
             $objTemplate->height = $imgSize[1];
         }
     } else {
         parent::addImageToTemplate($objTemplate, $arrItem, $intMaxWidth, $strLightboxId);
     }
 }
 /**
  * Add an image to a template.
  *
  * @param AddImageToTemplateEvent $event The event.
  *
  * @return void
  */
 public function handleAddImageToTemplate(AddImageToTemplateEvent $event)
 {
     Controller::addImageToTemplate($event->getTemplate(), $event->getImageData(), $event->getMaxWidth(), $event->getLightboxId());
 }
Esempio n. 3
0
 /**
  * Add video data to the template
  *
  * @param FrontendTemplate $template
  */
 public function addToTemplate(FrontendTemplate $template)
 {
     $template->setData($this->data);
     $template->id = $this->id;
     // Add lightbox features
     if ($this->lightbox) {
         $template->lightbox = true;
         $template->lightboxAutoplay = $this->lightboxAutoplay ? true : false;
         $template->lightboxSize = $this->lightboxSize;
     }
     // Add link features
     if ($this->link) {
         $template->internalLink = true;
         $template->linkUrl = $this->linkUrl;
         $template->linkTitle = $this->linkTitle;
     }
     // Add poster
     if ($this->poster !== null) {
         $posterHelper = new \stdClass();
         Controller::addImageToTemplate($posterHelper, ['singleSRC' => $this->poster, 'size' => $this->posterSize]);
         $template->poster = $posterHelper;
     }
     $template->customName = $this->customName;
     $template->album = $this->album !== null ? $this->album->getData() : [];
 }