0

In the frontend, the images URLs and blocks are not rendered. only show strings like this, and I don't know how to modify a template to render that.

{{media url="wysiwyg/1S-Shine-2.png"}}

  • are you which magento version ? – Sourav Apr 19 '18 at 4:20
  • Are you using this in template files or cms pages? – Geethika Antony Apr 19 '18 at 4:32
  • This is in cms pages, magento 2 – jacr1614 Apr 19 '18 at 16:06
0

The following is used to render images in Cms pages and blocks.

{{media url="wysiwyg/1S-Shine-2.png"}}

If you want to include an image in your template file use the following function in the corresponding block of your template file:

In your template Block file create __construct function.

protected $_storeManager;

public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager)
{
       $this->_storeManager = $storeManager;
}


public function getMediaBaseUrl() {
    $mediaUrl = $this ->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
    return $mediaUrl
}

And use this function in your template like below:

<img src="<?php echo $block->getMediaBaseUrl() ?>wysiwyg/1S-Shine-2.png">

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.