0

I've created a product attribute to display content in the product tabs which is specifically for technical drawings. The attribute is set as text editor type.

When I add an image using the "insert image" button the code is correct, as follows:

<img src="{{media url="diagrams/MCP-Typical-Wiring.jpg"}}" alt="" />

However, this doesn't display on the frontend, it is outputting as text:

<img src="{{media url=" diagrams="" mcp-typical-wiring.jpg"}}"="" alt="">

Does anyone have a fix for this?

  • I have faced the same issue in my magento 2.3.1 project and i have resolved this issue the method I mentioned below – Adarsh Ediyottil May 30 at 9:38
  • Thanks - can you help with where I should add this code please? I have used the block class Magento\Catalog\Block\Product\View in my catalog_product_view.xml file and linked this to a new .phtml file which calls the new attribute I created. – M Cain May 30 at 12:07
  • You can override Magento\Catalog\Block\Product\View in your custom module and pass that attribute value to a custom function from the template file. Refer magento.stackexchange.com/questions/95697/…. Or its feel difficult for you, your can try object manager. Using object manager in the template file is not a good practice – Adarsh Ediyottil May 31 at 11:22
0

You need to filter that editor content using cms page filter. in your block class

Try following way:

public function __construct(
    \Magento\Cms\Model\Template\FilterProvider $filterProvider)
    {
      $this->_filterProvider = $filterProvider;                       
     }

Now use $this->_filterProvider->getPageFilter()->filter($content);

  • Thanks for the reply, where would I add this code? – M Cain May 30 at 10:54

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.