public function thumbnailAddAction() { $alreadyExist = false; try { Asset_Image_Thumbnail_Config::getByName($this->_getParam("name")); $alreadyExist = true; } catch (Exception $e) { $alreadyExist = false; } if (!$alreadyExist) { $pipe = new Asset_Image_Thumbnail_Config(); $pipe->setName($this->_getParam("name")); $pipe->save(); } $this->_helper->json(array("success" => !$alreadyExist)); }
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())); } } } $pipe->save(); } // backup thumbnail table $db = Pimcore_Resource::get(); $tableData = $db->fetchAll("SELECT * FROM thumbnails"); $dumpData = ""; foreach ($tableData as $row) { $cells = array(); foreach ($row as $cell) { $cells[] = $db->quote($cell); } $dumpData .= "INSERT INTO `thumbnails` VALUES (" . implode(",", $cells) . ");"; $dumpData .= "\n"; } if (!is_dir(PIMCORE_BACKUP_DIRECTORY)) { mkdir(PIMCORE_BACKUP_DIRECTORY);