magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.57k stars 9.32k forks source link

Pagebuilder not using dynamic URL when selecting image in text element #39295

Open mdevrees opened 1 month ago

mdevrees commented 1 month ago

Preconditions and environment

Steps to reproduce

  1. Make sure the pagebuilder is used and Use Static URLs for Media Content in WYSIWYG is set to No (Stores > Config > General > Content Management > WYSIWYG Options)
  2. Create a new CMS page (Content > [Elements] Pages). Allow for all stores
  3. When adding content, first add a row and within that row add a Text element
  4. Insert/edit Image button
  5. On the right side of the Source field, press the 'browse files' button. This opens the Select Images overlay
  6. Upload a new image and then select that image.

Expected result

The URL field is filled with the dynamic media url ({{media url="/path/to/image.jpg"}}) but instead a fully resolved url is shown.

This result is expected because we use an internally uploaded image and it is not referring to a third party source.

Actual result

The URL to the selected image is completely resolved. Meaning that every website will resolve the same image. This causes issues with CSP.

Additional information

This is a multi-website shop and some sites share the same CMS information, so not all pages are linked to a store ID. Having a resolved URL means that the frontend will load images from another domain.

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 month ago

Hi @mdevrees. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.

m2-assistant[bot] commented 1 month ago

Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Bravo commented 4 weeks ago

Hi @mdevrees,

Thanks for your reporting and collaboration.

We have verified the issue in Latest 2.4-develop instance and the issue is not reproducible.kindly refer the screenshots.

Screenshot 2024-10-28 at 10 09 11

The URL field is filled with the dynamic media url ({{media url="/path/to/image.jpg"}})

Could you please let us know if we are missing anything.

Thanks.

mdevrees commented 4 weeks ago

Hi @engcom-Bravo

Thanks for checking. I checked with a clean Magento 2.4.7-p3 instance now and below is my result:

Screenshot 2024-10-28 at 16-55-44 Home page _ Pages _ Elements _ Content _ Magento Admin

I did the same steps as mentioned in the description: add a row, within that row add a Text element and in that Text element select an image.

I could also try 2.4-develop, what would be the composer install command for that?

engcom-Bravo commented 3 weeks ago

Hi @mdevrees,

Thanks for your update.

Could you please also try to reproduce in Latest Version Magento 2.4.8-beta1.For installing Magento 2.4-develop you can use this command git clone https://github.com/magento/magento2.git

Thanks.

mdevrees commented 3 weeks ago

Hi @engcom-Bravo

I installed 2.4.8-beta1 (this tag specifically), I notice that the tinymce editor now uses the {{media url=""}} correctly. It looks like my issue pertains specifically to the usage of Pagebuilder. I'm going to check the pagebuilder results in more detail and will report back when I know more.

mdevrees commented 3 weeks ago

Hi @engcom-Bravo

I investigated a bit with a few different Magento versions, below are my findings:

Clean Magento Open Source 2.4.8-beta1:

Clean Magento Open Source version 2.4.7-p3 (comes with Page builder):

Clean Magento Open Source version 2.4.6-p8 (comes with Page builder):

Clean Adobe Commerce Enterprise version 2.4.6-p8 (comes with Page builder):

Installation of both Open Source versions is done via composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition

I validate the contents of the cms page in the cms_page table, contents column. Run that through a html formatter to get output like below

Correct:

<style>#html-body [data-pb-style=MH6F3XF]{justify-content:flex-start;display:flex;flex-direction:column;background-position:left top;background-size:cover;background-repeat:no-repeat;background-attachment:scroll}</style>
<div data-content-type="html" data-appearance="default" data-element="main">&lt;p&gt;CMS homepage content goes here.&lt;/p&gt;</div>
<div data-content-type="row" data-appearance="contained" data-element="main">
   <div data-enable-parallax="0" data-parallax-speed="0.5" data-background-images="{}" data-background-type="image" data-video-loop="true" data-video-play-only-visible="true" data-video-lazy-load="true" data-video-fallback-src="" data-element="inner" data-pb-style="MH6F3XF">
      <div data-content-type="text" data-appearance="default" data-element="main">
         <p><img src="{{media url=&quot;.renditions/wysiwyg/anwb-woonwerk.png&quot;}}" alt="" width="1000" height="780"></p>
      </div>
   </div>
</div>

Incorrect:

<style>#html-body [data-pb-style=UX52J5W]{justify-content:flex-start;display:flex;flex-direction:column;background-position:left top;background-size:cover;background-repeat:no-repeat;background-attachment:scroll}</style>
<div data-content-type="html" data-appearance="default" data-element="main">&lt;p&gt;CMS homepage content goes here.&lt;/p&gt;</div>
<div data-content-type="row" data-appearance="contained" data-element="main">
   <div data-enable-parallax="0" data-parallax-speed="0.5" data-background-images="{}" data-background-type="image" data-video-loop="true" data-video-play-only-visible="true" data-video-lazy-load="true" data-video-fallback-src="" data-element="inner" data-pb-style="UX52J5W">
      <div data-content-type="text" data-appearance="default" data-element="main">
         <p><img id="CFGHY7S" style="width: 1000px; height: 780px;" src="https://magento.lndo.site/media/.renditions/wysiwyg/anwb-woonwerk.png" alt="" width="1000" height="780"></p>
         <p>This is extra text below the image</p>
      </div>
   </div>
</div>

Is there a 2.4.8-beta1 version available that includes Page builder? Then I could also test it on that version.

hostep commented 3 weeks ago

@mdevrees: good work!

You can also install 2.4.8-beta1 using composer, which will come with pagebuilder included:

$ composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.8-beta1 ./some-directory
engcom-Bravo commented 3 weeks ago

@hostep Thanks for your Contribution.

Hi @mdevrees,

Thanks for your update.

Could you please try with installing 2.4.8-beta1 using composer(with pagebuilder) and please let us know if you are still facing any issue.

Thanks.

mdevrees commented 3 weeks ago

Hi @engcom-Bravo

I installed with 2.4.8-beta1 and I observed the same functionality/ issue as described in my previous post.

Clean Magento Open Source version 2.4.8-beta1 (comes with Page builder):

<style>#html-body [data-pb-style=DUQ883O]{justify-content:flex-start;display:flex;flex-direction:column;background-position:left top;background-size:cover;background-repeat:no-repeat;background-attachment:scroll}</style><div data-content-type="html" data-appearance="default" data-element="main">&lt;p&gt;CMS homepage content goes here.&lt;/p&gt;
</div><div data-content-type="row" data-appearance="contained" data-element="main"><div data-enable-parallax="0" data-parallax-speed="0.5" data-background-images="{}" data-background-type="image" data-video-loop="true" data-video-play-only-visible="true" data-video-lazy-load="true" data-video-fallback-src="" data-element="inner" data-pb-style="DUQ883O"><div data-content-type="text" data-appearance="default" data-element="main"><p><img style="width: 884px; height: 617px;" src="https://magento.lndo.site/media/.renditions/wysiwyg/2024-05-31_13-43.png" alt="" width="884" height="617"></p>
<p>this is text after image</p></div></div></div>
engcom-Bravo commented 2 weeks ago

Hi @mdevrees,

Thanks for your update.

We have verified the issue in Latest 2.4-develop instance and the issue is reproducible.Kindly refer the screenshots.

Image and text combined

Screenshot 2024-11-08 at 10 37 00

using only image

Screenshot 2024-10-28 at 10 09 11

Pagebuilder resolves media url when image and text are combined

Hence Confirming the issue.

Thanks.

github-jira-sync-bot commented 2 weeks ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-13327 is successfully created for this GitHub issue.

m2-assistant[bot] commented 2 weeks ago

:white_check_mark: Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.