Admin_AssetController::getDocumentThumbnailAction PHP Метод

getDocumentThumbnailAction() публичный Метод

    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");
        }
        $thumb = $document->getImageThumbnail($thumbnail, $page);
        $thumbnailFile = $thumb->getFileSystemPath();
        $format = "png";
        header("Content-type: image/" . $format, true);
        header("Content-Length: " . filesize($thumbnailFile), true);
        $this->sendThumbnailCacheHeaders();
        while (@ob_end_flush()) {
        }
        flush();
        readfile($thumbnailFile);
        exit;
    }