- Issue created by @lindsay.wils
- π³π±Netherlands eelkeblok Netherlands π³π±
It looks like the regular expresion https://git.drupalcode.org/project/convert_entity_media_embed/-/blob/1.0... won't match your tags because there is an between the opening and closing tag. Obviously we can't "just" add it, because that would break it for other users. You could consider making the change yourself. That would look something like this:
$value['value'] = preg_replace_callback( '/<drupal-entity(.*)data-entity-type="media"(.*)> <\/drupal-entity>/', [static::class, 'getDrupalMediaTag'], $originalValue );
I am open to suggestions to make the code more flexible in what it will accept. I am a little worried .* between the tags would inadvertently match too much.
- π³π±Netherlands eelkeblok Netherlands π³π±
Adjusted the issue title.
- π¨π¦Canada lindsay.wils
Thank you for the response and info. Thing is, the nbsp; isnt something I have put in there, it is just the default of all of my source code on multiple different sites too.
Is it possible to match the nbsp; OR nothing between the tags?
chatGPT confirmed with me this should work
$value['value'] = preg_replace_callback(
'/(?: |)<\/drupal-entity>/',
[static::class, 'getDrupalMediaTag'],
$originalValue
);source
https://chat.openai.com/share/123fc68b-702b-49ac-86dc-4b1b3769d3eaSorry, Im not up to speed on submitting patches. Appreciate any help.
- π³π±Netherlands eelkeblok Netherlands π³π±
Thatβs certainly possible. I am curious what the source of that nbsp is, considering that no one has encountered it before. If we understand that, we can better assess whether we can expect other βcontentβ between the tags.
- π³π±Netherlands eelkeblok Netherlands π³π±
A very "90% easy, the rest possible" approach might also be to make the entire regex configurable... Maybe with an accompanying, mandatory, "Trust me, I know what I'm doing" checkbox...
- π¨π¦Canada lindsay.wils
Personally, I ended up having a different workaround for this and no longer needed to run the replace, but a configurable regex sounds like a good idea to allow broader control.
For my case, Im honestly not sure where the nbsp; came from, it was just using a normal entity embed setup to embed old D8 file entities using an Embed Button.
- First commit to issue fork.
- π³π±Netherlands eelkeblok Netherlands π³π±
I like this solution, because it only accepts nothing or a single nbsp. That should not pose any risks.
-
eelkeblok β
committed d359e303 on 1.0.x authored by
cbfannin β
Issue #3417889 by cbfannin, eelkeblok, lindsay.wils: Module doesn't...
-
eelkeblok β
committed d359e303 on 1.0.x authored by
cbfannin β
- Status changed to Fixed
10 months ago 9:45am 15 February 2024 Automatically closed - issue fixed for 2 weeks with no activity.