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')->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')->create(); $image->open($thumb); $resultRaw->setHeader('Content-Type', $image->getMimeType()); $resultRaw->setContents($image->getImage()); return $resultRaw; } else { // todo: generate some placeholder } } }