Ckeditor5 media embed plugin should preserve existing query parameters

Created on 9 October 2023, over 1 year ago

Problem/Motivation

Under certain circumstances, the (JS) code in DrupalMediaEditing._fetchPreview may fail to fetch a preview because it won't handle query parameters included in the previewUrl variable passed down from the server properly.

Steps to reproduce

On vanilla D10 10.1.x

  1. Install the layout_builder, media_library, wse modules
  2. Enable layout builder on the article content type enabling layout overrides for any article
  3. Enable the Embed media toolbar item and filter in the Basic HTML text format
  4. Add $config['wse.settings']['append_current_workspace_to_url'] = TRUE; to settings.php
  5. Create and article and edit it's layout
  6. Add a block of type Basic block to the layout and insert an image media (uploading a new image) in the body field, save the block
  7. Click the Configure contextual link on the added block

Expected result: The editor loads the added image
Actual result: The editor displays an error message An error occurred while trying to preview the media. Please save your work and reload this page.

Proposed resolution

Ensure existing query parameters get included in the request sent by DrupalMediaEditing._fetchPreview()

I realize one may argue this is a WSE problem, but the scenario of other pre-existing query parameters is nonetheless realistic and the core code should be able to handle this case.

🐛 Bug report
Status

Active

Version

10.1

Component
CKEditor 5 

Last updated about 18 hours ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024