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())?>"/>
Was it helpful?

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

OTHER TIPS

love coding.

Have you tried this approach?

https://magento.stackexchange.com/a/133009/92898

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top