Problem/Motivation
In js/wysiwyg-media.js the media tokens are replaced with real <img> tags so content editors can see the image in the rich text editor.
After clicking "save" button, in some cases (eg when using image2 plugin) there may be multiple classes added to the image tag, and when this happens, if "media-image" is not the *first* class, then the conversion back to Media tokens fails.
Proposed resolution
There are two possible solutions to this:
1) Modify the regular expression used to detect images with media-image class, to allow media-image anywhere inside the class attribute.
2) Convert the plain HTML string to a jQuery object and use a jQuery selector $('img.media-image') to find media placeholder images.
Remaining tasks
Review patch for Solution #1, to determine if this solution is sufficient.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | media-wysiwyg-ckeditor-image2-2433083-3.patch | 700 bytes | jwilson3 |
| #2 | media-wysiwyg-ckeditor-image2-2433083-2.patch | 700 bytes | jwilson3 |
Comments
Comment #1
jwilson3Comment #2
jwilson3I've opted for solution 1 because the change is a one-liner. It is a little bit complicated to read, but essentially, with the addition of
([^\'"]*?)to the regular expression, I've added the ability for additional classes to appear before the image-media class on the image tag.Comment #3
jwilson3Switched from + to * to allow zero or more characters.
Comment #4
jwilson3Comment #5
chris matthews commentedClosing this issue as outdated. However, if you think this issue is still important, please let us know and we will gladly re-open it for review.
sincerely,
- the Drupal Media Team