2

I'm trying to get image which is inserted in /app/design/frontend/Mytheme/themename/media folder using following code but it's shows 404 not found. I have also apply cache clean & static content deploy command but still not working. I'm using below code in my phtml file:-

$mediaurl = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
$image = $mediaurl."myimg.png";
echo $image;

So is it possible to get images of media folder in M2? Any suggestion should be appreciated. Thanks.

0

try this:

$block->getViewFileUrl('media/myimg.png');
  • Hi. Still not working. – Raj Oct 2 '18 at 13:39
  • @Raj i am using same code for display image. do as follow: copy your image in vendor/theme/web/media/ and add this code in phtml file to get this image to display – shyopat Oct 3 '18 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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