1

I am running Magento CE 2.2.2 and I need to create another TAB in the product information page near the details and review tabs.

I created a new Attribute, named it "Tab". In the attribute, options set the input type to Text Area and enabled WYSIWYG Editor.

When I put Text in the field, the text shows fine. When I insert an image, in backend shows fine, but in frontend, it shows broken.

When inspected the code noticed that the code is generated wrong.

the code shows like this:

<img src="{{media url=" wysiwyg="" rohs-weee.jpg"}}"="" width="800" height="233">

when it should show like this:

<img src="http://10.1.1.30/Magento2.2.2/pub/media/wysiwyg/RoHS-WEEE.jpg" width="800" height="233">

I am thinking that I missed some link to convert the link from the editor to the actual link. Does anyone know how to fix this?

This is a link to download the code of my block: https://www.dropbox.com/s/xmi7pvkd206s7vd/Test_Tab.zip?dl=0

  • Please check my answer and let me know if your question not solve. – Rohan Hapani Oct 19 '18 at 10:11
0

If I recall correctly you need to filter the WYSIWYG output to convert it to the proper markup using the FilterProvider.

Extend the template block class and inject the filter provider: \Magento\Cms\Model\Template\FilterProvider.

Add a new method to your class:

public function renderOutput($wysiwygCode) {
  return $this->filterProvider
    ->getBlockFilter()
    ->filter($wysiwygCode);
}

Then use the renderOutput method in your template.

0

You can get by this below code. Add this code in your phtml :

$content = '<img src="{{media url=" wysiwyg="" rohs-weee.jpg"}}"="" width="800" height="233">';
$om = \Magento\Framework\App\ObjectManager::getInstance();
$filterManager = $om->get('Magento\Cms\Model\Template\FilterProvider')->getPageFilter()->filter($content);
echo $filterManager;
0

If your description.phtml is shows the "Tab" field data, then please use following code for appropriate data of "Tab" attribute.

<?= /* @escapeNotVerified */ $this->helper('Magento\Catalog\Helper\Output')->productAttribute($block->getProduct(), $block->getProduct()->getTab(), 'tab') ?>

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.