Improve the Editor plugin behaviour supports image styles and uses DOM parser

Created on 17 May 2021, almost 4 years ago
Updated 28 April 2023, almost 2 years ago

Problem/Motivation

The module attempts to update all references to src with the basic file URL, however this isn't always the case, for example in Gutenberg, the src reference can be image styles.

There are also a couple of other minor issues:

  • preg_match only matches against the first occurrence, whereas there could be multiple references to that uuid within the content.
  • I think a DOM parser should be used rather than regex (just like the editor module does), as it improves the flexibility/predictability of the module. e.g. being aware of what src attribute you're modifying
  • The plugin replaces all src attributes with the default src, whereas it's possible for the src value to be an image style URL, and there should be room for the module to attempt to update those as well.

These would make sense to be addressed in the Editor plugin as once it makes changes to the entity's field contents, it's hard for a different module to do the same effectively.

On a side note: it'd be nice if there was functionality for setting the weight of the plugins, so third parties can control the order better. Either in a "weight" property, or an alter hook in the FileUpdateManager.

Steps to reproduce

N/A

Proposed resolution

Address all the issues pointed in an issue fork.

Remaining tasks

Push to issue fork and submit a patch.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024