0

Add this code WYSIWYG Editor

<p><img src="{{media url="wysiwyg/menu/test.jpg"}}" alt=""></p>

but it's not working in magento 2.4.0

enter image description here

1 Answer 1

2

Please try the below code.

/**
 * @var \Magento\Cms\Model\Template\FilterProvider
 */
protected $filterContent;

/**
 * @param \Magento\Framework\App\Helper\Context $context
 * @param \Magento\Cms\Model\Template\FilterProvider $filterContent
 */
public function __construct(
    \Magento\Framework\App\Helper\Context $context,
    \Magento\Cms\Model\Template\FilterProvider $filterContent
) {
    parent::__construct($context);
    $this->filterContent = $filterContent;
}

/**
 * Get filter content
 * @param  string $content
 * @return string
 */
public function getFilterContent($content)
{
    return $this->filterContent->getPageFilter()->filter($content);
}

https://prnt.sc/10us8xa

https://prnt.sc/10us96r

Let me know if you still face any issues.

2
  • which file code update? And this issue is face megamenu WYSIWYG Editor. Commented Mar 25, 2021 at 5:38
  • where do you show the image? Which is added in WYSIWYG editor.
    – ZealousWeb
    Commented Mar 26, 2021 at 7:19

Your Answer

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

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