In this function
protected function _prepareToRender() { $this->addColumn( 'attribute', [ 'label' => __('Select Attribute'), 'renderer' => $this->getAttributeRenderer(), ] ); $this->addColumn( 'test_thumbnail', array( 'header' => __('Image'), 'index' => 'test_thumbnail', 'renderer' => 'xxxxxxx\xxxxxxxxx\Block\Adminhtml\Product\Attribute\Edit\Tab\Renderer\Image', ) ); $this->addColumn('test_content',['label' => __('Test Content')]); $this->addColumn('position', ['label' => __('Position')]); $this->_addAfter = false; $this->_addButtonLabel = __('Add'); }
Please help.
Please use the below code
$this->addColumn( 'image', [ 'header' => __('Image'), 'index' => 'image', 'type' => 'image', 'frame_callback' => array($this, 'callback_image'), ] );
public function callback_image($value) { if (empty($value)){ return ''; } $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $mediaUrl = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); $width = 150; return "<img src='" . $mediaUrl . $value . "' width='" . $width . "'/>"; }
Hi @Sanjay Jethva
I have tried your same code
$this->addColumn( 'question_thumbnail', [ 'header' => __('Image'), 'index' => 'question_thumbnail', 'type' => 'image', 'frame_callback' => array($this, 'callback_image'), ] );
I am getting "question_thumbnail is not defined" in console and still iam getting the text field in grid edit page instead of image type.
https://ibb.co/yQXHwjJ
I need to add image column here after the select attribute column.
On click Add dynamic rows will add. In that each row will select an attribute(color, size etc.,) and need to browse and upload an image for each selected attribute.