1

We have Use Static URLs for Media Content in WYSIWYG set to No. And if we insert images with the "Insert Images..." button when the wysiwyg editor is hidden, it works. It inserts something like:

<img src="{{media url="wysiwyg/image.jpg"}}" alt="" />

It gets the correct data to insert using the link:

/admin/cms/wysiwyg_images/onInsert/key/<formkey>/?isAjax=true

Sending filename, node, store, as_is = 1, force_static_path = 0 and form_key. Some of this data is base64encoded

With the wysiwyg editor the element inserted is something like:

<img src="wysiwyg/image.jpg" alt="">

I see it tries to access 2 urls.

/admin/catalog/product/edit/id/1586/key/<formkey>/wysiwyg/image.jpg

Getting the error:

1 exception(s):
Exception #0 (Exception): Warning: DOMDocument::loadXML(): Empty string supplied as input in /vendor/magento/framework/View/Element/UiComponent/Config/DomMerger.php on line 327

And the url:

/pub/static/version1659521589/wysiwyg/image.jpg

getting the error:

Requested path 'wysiwyg/image.jpg' is wrong.
<pre>#1 Magento\Framework\App\StaticResource->launch() called at [vendor/magento/framework/App/Bootstrap.php:263]
#2 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\StaticResource#000000007ce5886c0000000018f98acf#) called at [pub/static.php:13]
</pre>

EDIT

I installed a test version of 2.4.4, with TinyMCE 5, and after selecting the image to add. In the Insert/Edit Image dialog, the Source valur is different from the previous results:

admin/cms/wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvZHVja2h1bnQuanBlZyJ9fQ,,/key/<formkey>/

It gets the result after accessing:

admin/cms/wysiwyg_images/onInsert/key/<formkey>/?isAjax=true

So maybe the problem is the url used in TinyMCE4 in my Magento 2.4.1.

1 Answer 1

0

It is possible that the database value base_media_url is empty. Check it with the following queries:

SELECT value FROM core_config_data WHERE path='web/secure/base_media_url';
SELECT value FROM core_config_data WHERE path='web/unsecure/base_media_url';

You can update both values with the queries:

UPDATE core_config_data SET value = '/path/to/media' WHERE path LIKE 'web/secure/base_media_url';
UPDATE core_config_data SET value = '/path/to/media' WHERE path LIKE 'web/unsecure/base_media_url';
3
  • @sadlyblue I believe that Magento 2 URLs should be the full URL to the media directory, just like in Magento 1. I think that you can use placeholders such as {{unsecure_base_url}} as well. But double-check that, as I'm also just stepping into Magento 2 and it is full of surprises. Let me know ))
    – dotancohen
    Aug 3 at 15:41
  • Yes they are null. I tried several values, clearing cache everytime. Only {{secure_base_url}}pub/media/ showed the images in the select image dialog. But it still adds the same code to the description, with the same errors when i click Ok to add the image.
    – sadlyblue
    Aug 3 at 15:44
  • 1
    I just checked on a default install, and the values are NULL here as well. But adding images works fine (v 2.4.4).
    – dotancohen
    Aug 3 at 18:17

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.