how to display images stored in pub/media folder
-
15-04-2021 - |
Question
hello everyone I want to display an image from the folder "pub/media" and concatinate it with my path from the image field from database but I can't display it in detail page with the ways that I have tested
can anyone help me please
this is what I have done with 2 ways
method 1
<p><?php echo __('image') ?>: <img src="<?= $user->getImg() ?>" alt="image" /></p>
method 2
$pathmedia = "pub/media";
<img src="<?php echo $block->getUrl($pathmedia."/".$user->getImg())?>"/>
La solution
Use something like this
<img src="<?php echo $this->getUrl('pub/media').$user->getImg(); ?>" />
Hoping this will contain path of image coming form database.
Happy coding
Autres conseils
love coding.
Have you tried this approach?
https://magento.stackexchange.com/a/133009/92898
Hope this helps.
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange