Magento – Magento2 – Wysiwyg images show broken thumbnail

magento-2.1magento-2.1.7magento2tinymcewysiwyg

When I insert a image in the wysiwyg editor (TinyMCE) the image shows properly in the frontend but gets a broken thumbnail image in the editor.

tinymce_broken_thumbnail_image

The url it generates in the editor is similar to this:

http://domain.extension/admin_url/cms/wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvcGRmL3BkZi5wbmcifX0,/key/8590a46185af57614af635e08360284c95f20261aa5adaf006acc019ed2e87ca/

Is there a way to show the image properly in the editor?

I'm using magento version 2.1.7

Best Answer

I solved this problem by adding this line:

'add_directives' => true,

in this file

/vendor/magento/module-cms/Model/Wysiwyg/Config.php

the block should looks like this:

 $config->setData(
        [
            'enabled' => $this->isEnabled(),
            'hidden' => $this->isHidden(),
            'use_container' => false,
            'add_variables' => true,
            'add_widgets' => true,
            'no_display' => false,
            'encode_directives' => true,
            'baseStaticUrl' => $this->_assetRepo->getStaticViewFileContext()->getBaseUrl(),
            'baseStaticDefaultUrl' => str_replace('index.php/', '', $this->_backendUrl->getBaseUrl())
                . $this->filesystem->getUri(DirectoryList::STATIC_VIEW) . '/',
            'directives_url' => $this->_backendUrl->getUrl('cms/wysiwyg/directive'),
            'popup_css' => $this->_assetRepo->getUrl(
                'mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css'
            ),
            'content_css' => $this->_assetRepo->getUrl(
                'mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css'
            ),
            'width' => '100%',
            'height' => '500px',
            'plugins' => [],
            'add_directives' => true,
        ]
    );

It is working in Magento 2.1.7

Related Topic