コード例 #1
0
ファイル: ImageViewHelper.php プロジェクト: kryzalid/Picasa
 /**
  * Resizes a given image (if required) and renders the respective img tag
  * @see http://typo3.org/documentation/document-library/references/doc_core_tsref/4.2.0/view/1/5/#id4164427
  *
  * @param string $src
  * @param string $width width of the image. This can be a numeric value representing the fixed width of the image in pixels. But you can also perform simple calculations by adding "m" or "c" to the value. See imgResource.width for possible options.
  * @param string $height height of the image. This can be a numeric value representing the fixed height of the image in pixels. But you can also perform simple calculations by adding "m" or "c" to the value. See imgResource.width for possible options.
  * @param integer $minWidth minimum width of the image
  * @param integer $minHeight minimum height of the image
  * @param integer $maxWidth maximum width of the image
  * @param integer $maxHeight maximum height of the image
  *
  * @return string rendered tag.
  * @author Sebastian Böttger <*****@*****.**>
  * @author Bastian Waidelich <*****@*****.**>
  */
 public function render($src, $width = NULL, $height = NULL, $minWidth = NULL, $minHeight = NULL, $maxWidth = NULL, $maxHeight = NULL)
 {
     if (strpos($src, 'http') !== 0) {
         return parent::render($src, $width, $height, $minWidth, $minHeight, $maxWidth, $maxHeight);
     }
     $hash = md5($src);
     $cachedImage = $this->cachePath . $hash . '.' . pathinfo($src, PATHINFO_EXTENSION);
     if (!file_exists(PATH_site . $cachedImage)) {
         $this->fetchAndCacheImage($src, PATH_site . $cachedImage);
     }
     return parent::render($cachedImage, $width, $height, $minWidth, $minHeight, $maxWidth, $maxHeight);
 }
コード例 #2
0
 /**
  * Initialize arguments.
  *
  * @return void
  * @author Mario Matzulla <*****@*****.**>
  */
 public function initializeArguments()
 {
     parent::initializeArguments();
 }
コード例 #3
0
 /**
  * Render an image from the upload folder of the Nxproducts extension
  *
  * @param string $src
  * @param string $width width of the image. This can be a numeric value representing the fixed width of the image in pixels. But you can also perform simple calculations by adding "m" or "c" to the value. See imgResource.width for possible options.
  * @param string $height height of the image. This can be a numeric value representing the fixed height of the image in pixels. But you can also perform simple calculations by adding "m" or "c" to the value. See imgResource.width for possible options.
  * @param integer $minWidth minimum width of the image
  * @param integer $minHeight minimum height of the image
  * @param integer $maxWidth maximum width of the image
  * @param integer $maxHeight maximum height of the image
  * @param integer $maxImages if multiple images, maximum of images
  * @param string $wrap tag to wrap the image
  * @param boolean $absolute render absolute urls
  *
  * @return string rendered tag.
  * @author Noel Bossart <*****@*****.**>
  */
 public function render($src, $width = NULL, $height = NULL, $minWidth = NULL, $minHeight = NULL, $maxWidth = NULL, $maxHeight = NULL, $maxImages = NULL, $wrap = NULL, $absolute = NULL)
 {
     if (!$src) {
         return;
     }
     $srcs = explode(",", $src);
     if (is_array($srcs)) {
         // multiple images
         $code = '';
         $max = $maxImages ? $maxImages : count($srcs);
         for ($i = 0; $i < $max; $i++) {
             if (file_exists($srcs[$i])) {
                 $image_src = $srcs[$i];
             } else {
                 if (file_exists(Tx_Nxshowroom_Utility_Base::$UPLOAD_FOLDER . $srcs[$i])) {
                     $image_src = Tx_Nxshowroom_Utility_Base::$UPLOAD_FOLDER . $srcs[$i];
                 } else {
                     if (file_exists($image_src = Tx_Nxshowroom_Utility_Base::$PUBLIC_FOLDER . $srcs[$i])) {
                         $image_src = Tx_Nxshowroom_Utility_Base::$PUBLIC_FOLDER . $srcs[$i];
                     } else {
                         $image_src = false;
                     }
                 }
             }
             if ($image_src) {
                 $tempImage = parent::render($image_src, $width, $height, $minWidth, $minHeight, $maxWidth, $maxHeight);
                 if ($wrap) {
                     $tempImage = "<" . $wrap . ">" . $tempImage . "</" . $wrap . ">";
                 }
                 $code .= $tempImage;
             }
         }
     } else {
         // single images
         if (file_exists($src)) {
             $image_src = $src;
         } else {
             if (file_exists(Tx_Nxshowroom_Utility_Base::$UPLOAD_FOLDER . $src)) {
                 $image_src = Tx_Nxshowroom_Utility_Base::$UPLOAD_FOLDER . $src;
             } else {
                 if (file_exists($image_src = Tx_Nxshowroom_Utility_Base::$PUBLIC_FOLDER . $src)) {
                     $image_src = Tx_Nxshowroom_Utility_Base::$PUBLIC_FOLDER . $src;
                 } else {
                     $image_src = false;
                 }
             }
         }
         if ($image_src) {
             $code = parent::render($image_src, $width, $height, $minWidth, $minHeight, $maxWidth, $maxHeight);
             if ($wrap) {
                 $code = "<" . $wrap . ">" . $code . "</" . $wrap . ">";
             }
         }
     }
     if ($absolute) {
         $code = str_replace('src="', 'src="http://' . $_SERVER['SERVER_NAME'] . '/', $code);
     }
     return $code;
 }