Skip to content

The function "isUsingStaticUrlsAllowed" (configuration setting "cms/wysiwyg/use_static_urls_in_catalog") doesn't have any effect with the WYSIWYG editor image insertion #12147

@andrewhowdencom

Description

@andrewhowdencom

Preconditions

  1. 2.2.1
  2. PHP 7.x

Steps to reproduce

  1. Set the setting "cms/wysiwyg/use_static_urls_in_catalog"
  2. Add an image using the WYSIWYG editor in the admin panel
  3. Observe that the directive style URL is returned, not the static URL

Expected result

  1. The static URL (i.e. media URL without transformation) should be returned

Actual result

The directive URL is returned.

Magento uses specially formatted URLs of the form:

https://${ADMIN_DOMAIN}/cms/wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmVkMi5wbmcifX0,/key/${ADMIN_KEY}/

To be able to render images in the wysiwyg editor. These URLs have two purposes:

  1. They are able to be processed by the stack, and show the appropriate image, and
  2. They contain the CMS directive for insertion into the stack in base64 in the ___directive component.

However, in some situations stores may wish to disable this behaviour such that the URL is instead the standard URL for that scope:

https://${ADMIN_DOMAIN}/media/wysiwyg/bed2.png

This is controlled with the setting in the issue title. However, it currently has no effect. I think it likely broke here:

a978a4c

The controller on the frontend posts an empty store which s picked up by:

https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/OnInsert.php#L38

and stored as "". The problem is, the store configuration is either looking for a numeric store code, or the type null -- or it uses the configuration string exactly as supplied (i.e. ""):

https://github.com/magento/magento2/blame/2.2-develop/lib/internal/Magento/Framework/App/Config.php#L68

This malforms the path, queries the configuration tree but returns null. It is thus impossible to use that setting from the frontend.

It's possible that this is a bug in third party code, not supplying the string default in the post STORE. However, at this point I believe this to be a change in behaviour in upstream, and I will fix it accordingly.

Plan for this is just to check if store is "" in the OnInsert controller, and if it is, use null and not "".

Metadata

Metadata

Assignees

Labels

Fixed in 2.2.xThe issue has been fixed in 2.2 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions