Fatal error: Declaration of \ModuleName\Block\Adminhtml\ModuleName\Grid\Renderer\Image::render() must be compatible with Magento\Backend\Block\Widget\Grid\Column\Renderer\RendererInterface::render(Magento\Framework\DataObject $row) in C:\wamp\www\magento2\app\code\\ModuleName\Block\Adminhtml\ModuleName\Grid\Renderer\Image.php on line 59
<?php
namespace <vendor-name>\ModuleName\Block\Adminhtml\ModuleName\Grid\Renderer;
use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
use Magento\Framework\Object;
use Magento\Store\Model\StoreManagerInterface;
class Image extends AbstractRenderer
{
private $_storeManager;
/**
* @param \Magento\Backend\Block\Context $context
* @param array $data
*/
public function __construct(\Magento\Backend\Block\Context $context, StoreManagerInterface $storemanager, array $data = [])
{
$this->_storeManager = $storemanager;
parent::__construct($context, $data);
$this->_authorization = $context->getAuthorization();
echo "test";
}
/**
* Renders grid column
*
* @param Object $row
* @return string
*/
public function render(Object $row)
{
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
\Magento\Framework\UrlInterface::URL_TYPE_MEDIA
);
$imageUrl = $mediaDirectory.'/FolderPathName'.$this->_getValue($row);
return '<img src="'.$imageUrl.'" width="50"/>';
}
}