If you want to show image in grid that is possible, but if you want to show image in form, that wont be possible in magento, because image is not input field it would not appear on form.
But you can use image uploader instead of text field in you from
$this->addColumn(
'image',
[
'header' => __('Image'),
'index' => 'image',
'type' => 'image',
'frame_callback' => array($this, 'callback_image'),
]
);
To show image in grid you can do this:
$this->addColumn(
'image',
[
'header' => __('Image'),
'index' => 'image',
'type' => 'image',
'frame_callback' => array($this, 'callback_image'),
]
);
frame callback function 'frame_callback' => array($this, 'callback_image'),
will call a function and it runs like renderer
Function is:
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 . "LOCATION_OF_IMAGE" . $value . "' width='" . $width . "'/>";
}
Do these in your grid file, and image will appear on grid, instead of URL