public static getByAutoDetect ( $config ) : self | boolean | ||
$config | ||
Результат | self | boolean |
/** * @param $thumbnailName * @param int $page * @param bool $deferred $deferred deferred means that the image will be generated on-the-fly (details see below) * @return mixed|string */ public function getImageThumbnail($thumbnailName, $page = 1, $deferred = false) { // just 4 testing //$this->clearThumbnails(true); if (!\Pimcore\Document::isAvailable()) { \Logger::error("Couldn't create image-thumbnail of document " . $this->getFullPath() . " no document adapter is available"); return "/pimcore/static/img/filetype-not-supported.png"; } $thumbnail = Image\Thumbnail\Config::getByAutoDetect($thumbnailName); $thumbnail->setName("document_" . $thumbnail->getName() . "-" . $page); try { if (!$deferred) { $converter = \Pimcore\Document::getInstance(); $converter->load($this->getFileSystemPath()); $path = PIMCORE_TEMPORARY_DIRECTORY . "/document-image-cache/document_" . $this->getId() . "__thumbnail_" . $page . ".png"; if (!is_dir(dirname($path))) { \Pimcore\File::mkdir(dirname($path)); } $lockKey = "document-thumbnail-" . $this->getId() . "-" . $page; if (!is_file($path) && !Model\Tool\Lock::isLocked($lockKey)) { Model\Tool\Lock::lock($lockKey); $converter->saveImage($path, $page); Model\Tool\Lock::release($lockKey); } else { if (Model\Tool\Lock::isLocked($lockKey)) { return "/pimcore/static/img/please-wait.png"; } } } if ($thumbnail) { $path = Image\Thumbnail\Processor::process($this, $thumbnail, $path, $deferred); } return preg_replace("@^" . preg_quote(PIMCORE_DOCUMENT_ROOT) . "@", "", $path); } catch (\Exception $e) { \Logger::error("Couldn't create image-thumbnail of document " . $this->getFullPath()); \Logger::error($e); } return "/pimcore/static/img/filetype-not-supported.png"; }
/** * @param $selector * @return bool|static */ protected function createConfig($selector) { $config = Image\Thumbnail\Config::getByAutoDetect($selector); if ($config) { $format = strtolower($config->getFormat()); if ($format == "source") { $config->setFormat("PNG"); } } return $config; }
public function getDocumentThumbnailAction() { $document = Asset::getById(intval($this->getParam("id"))); $thumbnail = Asset\Image\Thumbnail\Config::getByAutoDetect($this->getAllParams()); $format = strtolower($thumbnail->getFormat()); if ($format == "source") { $thumbnail->setFormat("jpeg"); // default format for documents is JPEG not PNG (=too big) } if ($this->getParam("treepreview")) { $thumbnail = Asset\Image\Thumbnail\Config::getPreviewConfig(); } $page = 1; if (is_numeric($this->getParam("page"))) { $page = (int) $this->getParam("page"); } $thumbnailFile = PIMCORE_DOCUMENT_ROOT . $document->getImageThumbnail($thumbnail, $page); $format = "png"; header("Content-type: image/" . $format, true); header("Content-Length: " . filesize($thumbnailFile), true); $this->sendThumbnailCacheHeaders(); while (@ob_end_flush()) { } flush(); readfile($thumbnailFile); exit; }
/** * @param $config * @return Image\Thumbnail\Config|bool|Thumbnail */ public function getImageThumbnailConfig($config) { return Image\Thumbnail\Config::getByAutoDetect($config); }
/** * Get a thumbnail image configuration. * @param mixed $selector Name, array or object describing a thumbnail configuration. * @return Thumbnail\Config */ protected function createConfig($selector) { return Thumbnail\Config::getByAutoDetect($selector); }