Magento 2 – Editor WYSIWYG Not Resolving URL of Media Directive

javascriptmagento2wysiwyg

Currently i have normal form with editor field (wysiwyg) no-uicomponent implement.
When i insert image magento insertImage to content

<img src="{{media url="wysiwyg/test.png"}}" alt="" />

but after click on button Show / Hide Editor Editor content show

<p><img src="{{media url=" alt="" /></p>

Ofcourse my image not show. I expected that after click editor content must show my current image

What exactly happens, Where in code i should check to solve this problem?
i'm using Magento 2.1.2. Directory wysiwyg had full write permission

Best Answer

Please change this setting and check

Store -> Configuration -> General -> Content Management -> Use Static URLs for Media Content in

WYSIWYG for Catalog to Yes

But, there are some big drawbacks of doing this. The static URL which is used for media content in WYSIWYG might be non-secure URLs. In such cases, if you change the base URL the URLs on the images will not update to reflect that are two. Although, there is another solution available to fix this problem (not a great alternative in my opinion), but better than changing the static URL option.

Another Solution

Change vendor/magento/module-catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Add on line 747:

'add_variables' => false,
    'add_widgets' => false,
    'add_directives' => true,
    'use_container' => true,
    'container_class' => 'hor-scroll',

Change lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js

Add on line 384 below content = editor.getContent();

content = this.decodeContent(content);

Once done the above-mentioned changes follow the below commands

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento cache:flush

Hope this will help. But, keep in mind that you have just made changes in the core files. Once done, move these file to the local folder.

Related Topic