I used this answer to implement ui image uploader in my custom module.
It's working good. But whenever I go into edit the page image is not coming.
How can we show the uploaded image in edit page?
I used this answer to implement ui image uploader in my custom module.
It's working good. But whenever I go into edit the page image is not coming.
How can we show the uploaded image in edit page?
You need to add your custom image uploader data to DataProvider.php
Vendor/Module/Model/FaqGroup/DataProvider.php
public function getData()
{
...
$items = $this->collection->getItems();
foreach ($items as $model) {
$this->loadedData[$model->getId()] = $model->getData();
if ($model->getIcon()) {
// replace icon to your custom field name
$m['icon'][0]['name'] = $model->getIcon();
$m['icon'][0]['url'] = $this->getMediaUrl().$model->getIcon();
$fullData = $this->loadedData;
$this->loadedData[$model->getId()] = array_merge($fullData[$model->getId()], $m);
}
}
...
return $this->loadedData;
}
public function getMediaUrl()
{
$mediaUrl = $this->storeManager->getStore()
->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA).'faq/tmp/icon/';
return $mediaUrl;
}