Example #1
0
 /**
  * This is just for compatibility, this method will be removed with the next major release
  * @depricated
  * @static
  * @param $config
  * @return Asset_Image_Thumbnail_Config
  */
 public static function getByLegacyConfig($config)
 {
     $pipe = new Asset_Image_Thumbnail_Config();
     $hash = md5(Pimcore_Tool_Serialize::serialize($config));
     $pipe->setName("auto_" . $hash);
     if ($config["format"]) {
         $pipe->setFormat($config["format"]);
     }
     if ($config["quality"]) {
         $pipe->setQuality($config["quality"]);
     }
     /*if ($config["cropPercent"]) {
           $pipe->addItem("cropPercent", array(
               "width" => $config["cropWidth"],
               "height" => $config["cropHeight"],
               "y" => $config["cropTop"],
               "x" => $config["cropLeft"]
           ));
       }*/
     if ($config["cover"]) {
         $pipe->addItem("cover", array("width" => $config["width"], "height" => $config["height"], "positioning" => "center"));
     } else {
         if ($config["contain"]) {
             $pipe->addItem("contain", array("width" => $config["width"], "height" => $config["height"]));
         } else {
             if ($config["frame"]) {
                 $pipe->addItem("frame", array("width" => $config["width"], "height" => $config["height"]));
             } else {
                 if ($config["aspectratio"]) {
                     if ($config["height"] > 0 && $config["width"] > 0) {
                         $pipe->addItem("contain", array("width" => $config["width"], "height" => $config["height"]));
                     } else {
                         if ($config["height"] > 0) {
                             $pipe->addItem("scaleByHeight", array("height" => $config["height"]));
                         } else {
                             $pipe->addItem("scaleByWidth", array("width" => $config["width"]));
                         }
                     }
                 } else {
                     if (empty($config["width"]) && !empty($config["height"])) {
                         $pipe->addItem("scaleByHeight", array("height" => $config["height"]));
                     } else {
                         if (!empty($config["width"]) && empty($config["height"])) {
                             $pipe->addItem("scaleByWidth", array("width" => $config["width"]));
                         } else {
                             $pipe->addItem("resize", array("width" => $config["width"], "height" => $config["height"]));
                         }
                     }
                 }
             }
         }
     }
     return $pipe;
 }
<?php

$list = new Asset_Image_Thumbnail_List();
$list->load();
$thumbnails = array();
foreach ($list->getThumbnails() as $thumbnail) {
    $pipe = new Asset_Image_Thumbnail_Config();
    $pipe->setName($thumbnail->getName());
    $pipe->setDescription($thumbnail->getDescription());
    $pipe->setFormat($thumbnail->getFormat());
    $pipe->setQuality($thumbnail->getQuality());
    if ($thumbnail->getCover()) {
        $pipe->addItem("cover", array("width" => $thumbnail->getWidth(), "height" => $thumbnail->getHeight(), "positioning" => "center"));
    } else {
        if ($thumbnail->getContain()) {
            $pipe->addItem("contain", array("width" => $thumbnail->getWidth(), "height" => $thumbnail->getHeight()));
        } else {
            if ($thumbnail->getAspectratio()) {
                if ($thumbnail->getHeight() > 0 && $thumbnail->getWidth() > 0) {
                    $pipe->addItem("contain", array("width" => $thumbnail->getWidth(), "height" => $thumbnail->getHeight()));
                } else {
                    if ($thumbnail->getHeight() > 0) {
                        $pipe->addItem("scaleByHeight", array("height" => $thumbnail->getHeight()));
                    } else {
                        $pipe->addItem("scaleByWidth", array("width" => $thumbnail->getWidth()));
                    }
                }
            } else {
                $pipe->addItem("resize", array("width" => $thumbnail->getWidth(), "height" => $thumbnail->getHeight()));
            }
        }