![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-cms/Controller/Adminhtml/Wysiwyg/Images/ |
<?php /** * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Cms\Controller\Adminhtml\Wysiwyg\Images; use Magento\Backend\App\Action; class Thumbnail extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images { /** * @var \Magento\Framework\Controller\Result\RawFactory */ protected $resultRawFactory; /** * @param Action\Context $context * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory */ public function __construct( Action\Context $context, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory ) { $this->resultRawFactory = $resultRawFactory; parent::__construct($context, $coreRegistry); } /** * Generate image thumbnail on the fly * * @return \Magento\Framework\Controller\Result\Raw */ public function execute() { $file = $this->getRequest()->getParam('file'); $file = $this->_objectManager->get(\Magento\Cms\Helper\Wysiwyg\Images::class)->idDecode($file); $thumb = $this->getStorage()->resizeOnTheFly($file); /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */ $resultRaw = $this->resultRawFactory->create(); if ($thumb !== false) { /** @var \Magento\Framework\Image\Adapter\AdapterInterface $image */ $image = $this->_objectManager->get(\Magento\Framework\Image\AdapterFactory::class)->create(); $image->open($thumb); $resultRaw->setHeader('Content-Type', $image->getMimeType()); $resultRaw->setContents($image->getImage()); return $resultRaw; } else { // todo: generate some placeholder } } }