0

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

2 Answers 2

1

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

0

love coding.

Have you tried this approach?

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

Hope this helps.

2
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – sandip
    Nov 20, 2020 at 4:29
  • It makes sense, @sandip. Nov 20, 2020 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.