Magento2: Dynamic Media URLs in Products not working properly

Created on 27 Oct 2016  路  12Comments  路  Source: magento/magento2

Preconditions

  1. Magento CE 2.1.2
  2. PHP 7.0.10

Steps to reproduce

  1. Make sure the setting Allow Dynamic Media URLs in Products and Categories is set to Yes (in Catalog)
  2. Make sure the setting Use Static URLs for Media Content in WYSIWYG for Catalog is set to No (in Content Management)
  3. Open an existing product or create a new one
  4. Go to the Description field
  5. Hide the editor
  6. Click the Insert Image... button
  7. Select an image and insert it
  8. The editor field now has something like this: <img src="{{media url="wysiwyg/abc.jpg"}}" alt="" />
  9. Save the product
  10. Go to the Description field again and hide the editor again

    Expected result

  11. Expected result is that the description field still has: <img src="{{media url="wysiwyg/abc.jpg"}}" alt="" />

    Actual result

  12. The media directive has been stripped apart:
    <img src="{{media url=" alt="" />

    Discussion

This only seems to happen in products (maybe also categories). In CMS pages, this works as expected.

A second problem is if you do the same, but with the Editor enabled, and insert an image, it adds this html:
<img src="https://example.com/admin-url-identifier/cms/wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvRFNDRjcxNjYuanBdqsfdqds/key/1b2f66950dc8519c79a63dc568af88e0731f5ca997f819cede1d1624d4fqsdfqsdf/" />
This is even worse, it leaks the admin-url-identifier to the outside world, which is probably a security issue?
And if you work with deploys with a current/releases/shared directory structure (capistrano for example), this image only works until you do a next deploy. After a deploy this url is broken and the image doesn't show up again in the frontend or adminhtml.
I would have expected that with the editor enabled, we also would get this {{media}} type of url instead of the weird url we now get.

Catalog Format is valid Ready for Work bug report

Most helpful comment

Same issue with our current installation : Magento 2.2.1

All 12 comments

Duplicate of #6138 which is already acknowledged internally
MAGETWO-59690( for 2.1) and MAGETWO-57796( for 2.2.0)

@dthampy Just FYI... In version 2.1.2, media directives work (backend + frontend) for CMS pages , but not for product description and short description. Which i really don't understand... the same component should work properly everywhere and not just in one instance. I'm using this format by the way: {{media url=wysiwyg/icons/some_icon.png}}

Would be great if something crucial like this would be finally fixed in version 2.2.0 ;)

Current 2.1.3 i got same problem like this. Catalog Edit not work. Cms Page work

Currently 2.1.4 and I'm still experiencing the same issue.

Internal ticket to track issue progress: MAGETWO-70435

Same issue with my instalaltion: Magento 2.2.0

Same issue with our current installation : Magento 2.2.1

I _thought_ this was not resolved in 2.2, also. But Magento support said they could not reproduce it. So I created a new WYSIWYG text area attribute in attempt to reproduce this from "Step 1", and it _did_ work.

So then I edited and re-saved my existing text area attributes - _without changing any settings_ - and then my old attributes started processing the media url directives as well.

I'm not sure if the 2.2 upgrade forgot to update some table or something - but simply editing and re-saving the Attribute configuration in the Admin area resolved this, and the {{media}} directives are working on custom Product attributes now.

Same issue with our current installation : Magento 2.2.2 Community Edition

When inserting a media file from categories Content -> Description

The following src tag:

doesn't parse the string and display as it is in the page

Any workarounds ?

Can someone who still runs into these problems try to reproduce this on a clean Magento installation (preferably using the latest versions, so version 2.1.12 and 2.2.3 at the time of writing), since I'm pretty sure this first got fixed in 2.1.8, broken again in 2.1.9 and then fixed again in 2.1.11 and also fixed in 2.2.1 or 2.2.2, but if you can reproduce this on a clean installation feel free let us know, or maybe better, create a new issue.

Thanks! :)

On Magento 2.2.2 EE the issue still exists, dynamic urls do not work with:

  1. Product
  2. Category
  3. Content Banner
Was this page helpful?
0 / 5 - 0 ratings