function smarty_function_image($params, &$smarty)
{
    try {
        if (empty($params['src'])) {
            throw new Exception('No src parameter provided for the image');
        }
        $src = $params['src'];
        unset($params['src']);
        $image = new Image($src);
        if (!empty($params['thumbnail'])) {
            if (empty($params['width'])) {
                throw new Exception('No width parameter provided for the thumbnailer');
            }
            if (empty($params['height'])) {
                throw new Exception('No height parameter provided for the thumbnailer');
            }
            $image->setThumbnailer($params['thumbnail'], $params['width'], $params['height']);
            unset($params['thumbnail']);
            unset($params['width']);
            unset($params['height']);
        }
        foreach ($params as $key => $value) {
            $image->setAttribute($key, $value);
        }
        $html = $image->getHtml();
    } catch (Exception $exception) {
        Zibo::getInstance()->runEvent(Zibo::EVENT_LOG, $exception->getMessage(), $exception->getTraceAsString(), 1);
        $html = '<span class="red" style="color: red;">Could not load image: ' . $exception->getMessage() . '</span>';
    }
    return $html;
}
 /**
  * Decorates a cell which contains an Advertisement object
  * @param zibo\library\html\table\Cell $cell
  * @param zibo\library\html\table\Row $row
  * @param int $rowNumber
  * @param array $remainingValues
  * @return null
  */
 public function decorate(Cell $cell, Row $row, $rowNumber, array $remainingValues)
 {
     $advertisement = $cell->getValue();
     if (!$advertisement instanceof AdvertisementData) {
         return;
     }
     $cell->appendToClass('advertisement');
     try {
         $image = new Image($advertisement->image);
         $image->appendToClass('data');
         $image->setThumbnailer('crop', 50, 50);
         $value = $image->getHtml();
     } catch (Exception $e) {
         $value = 'Could not load image: ' . $e->getMessage();
     }
     $anchor = new Anchor($advertisement->name, $this->action . $advertisement->id);
     $value .= $anchor->getHtml();
     if (!$advertisement->clicks) {
         $advertisement->clicks = '0';
     }
     $translateParams = array('from' => $this->locale->formatDate($advertisement->dateStart), 'till' => $this->locale->formatDate($advertisement->dateStop), 'clicks' => $advertisement->clicks);
     $value .= '<div class="info">';
     $value .= $advertisement->website . '<br />';
     $value .= $this->translator->translate(self::TRANSLATION_DISPLAY, $translateParams) . '<br />';
     $value .= $this->translator->translate(self::TRANSLATION_CLICKS, $translateParams);
     $value .= '</div>';
     $cell->setValue($value);
 }
 /**
  * Gets the HTML for the image of the data
  * @param mixed $data
  * @return string
  */
 private function getImageHtml($data)
 {
     $modelTable = $this->meta->getModelTable();
     if (!$modelTable->hasDataFormat(DataFormatter::FORMAT_IMAGE)) {
         return '';
     }
     $image = $this->meta->formatData($data, DataFormatter::FORMAT_IMAGE);
     if ($image) {
         $image = new Image($image);
     } else {
         $image = new Image($this->defaultImage);
     }
     $image->setThumbnailer('crop', 50, 50);
     $image->appendToClass(self::STYLE_IMAGE);
     return $image->getHtml();
 }
 /**
  * Gets a preview of the provided value
  * @param string $value Path to the current file
  * @return string HTML of the value
  */
 protected function getPreviewHtml($value)
 {
     try {
         $file = new File($value);
         $image = new CoreImage($file);
     } catch (Exception $e) {
         return;
     }
     $image = new HtmlImage($value);
     $image->setThumbnailer(ThumbnailFactory::CROP, $this->previewWidth, $this->previewHeight);
     return '<span class="image">' . $image->getHtml() . '</span>';
 }