Example #1
0
 /**
  * @param  $config
  * @return Asset_Image_Thumbnail|bool|Thumbnail
  */
 public function getThumbnailConfig($config)
 {
     if (is_string($config)) {
         try {
             $thumbnail = Asset_Image_Thumbnail_Config::getByName($config);
         } catch (Exception $e) {
             Logger::error("requested thumbnail " . $config . " is not defined");
             return false;
         }
     } else {
         if (is_array($config)) {
             // check if it is a legacy config or a new one
             if (array_key_exists("items", $config)) {
                 $thumbnail = Asset_Image_Thumbnail_Config::getByArrayConfig($config);
             } else {
                 $thumbnail = Asset_Image_Thumbnail_Config::getByLegacyConfig($config);
             }
         } else {
             if ($config instanceof Asset_Image_Thumbnail_Config) {
                 $thumbnail = $config;
             }
         }
     }
     return $thumbnail;
 }
<?php

// rebuild thumbnails that have "cover" transformation in it
$dir = Asset_Image_Thumbnail_Config::getWorkingDir();
$files = scandir($dir);
foreach ($files as $file) {
    $found = false;
    if (strpos($file, ".xml")) {
        $name = str_replace(".xml", "", $file);
        $thumbnail = Asset_Image_Thumbnail_Config::getByName($name);
        foreach ($thumbnail->items as &$item) {
            if ($item["method"] == "cover") {
                $item["arguments"]["doNotScaleUp"] = "1";
                $found = true;
            }
        }
        if ($found) {
            unset($thumbnail->filenameSuffix);
            $thumbnail->save();
        }
    }
}
Example #3
0
 public function thumbnailUpdateAction()
 {
     $pipe = Asset_Image_Thumbnail_Config::getByName($this->_getParam("name"));
     $data = Zend_Json::decode($this->_getParam("configuration"));
     $items = array();
     foreach ($data as $key => $value) {
         $setter = "set" . ucfirst($key);
         if (method_exists($pipe, $setter)) {
             $pipe->{$setter}($value);
         }
         if (strpos($key, "item.") === 0) {
             $cleanKeyParts = explode(".", $key);
             $items[$cleanKeyParts[1]][$cleanKeyParts[2]] = $value;
         }
     }
     $pipe->resetItems();
     foreach ($items as $item) {
         $type = $item["type"];
         unset($item["type"]);
         $pipe->addItem($type, $item);
     }
     $pipe->save();
     $this->deleteThumbnailTmpFiles($pipe);
     $this->_helper->json(array("success" => true));
 }
 public function thumbnailUpdateAction()
 {
     $pipe = Asset_Image_Thumbnail_Config::getByName($this->_getParam("name"));
     $settingsData = Zend_Json::decode($this->_getParam("settings"));
     $itemsData = Zend_Json::decode($this->_getParam("items"));
     foreach ($settingsData as $key => $value) {
         $setter = "set" . ucfirst($key);
         if (method_exists($pipe, $setter)) {
             $pipe->{$setter}($value);
         }
     }
     $pipe->resetItems();
     foreach ($itemsData as $item) {
         $type = $item["type"];
         unset($item["type"]);
         $pipe->addItem($type, $item);
     }
     $pipe->save();
     $this->deleteThumbnailTmpFiles($pipe);
     $this->_helper->json(array("success" => true));
 }