Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
WYSIWYG editors like to wrap everything in paragraph tags, so a common scenario is this:
<p>My first paragraph.</p>
<p>[caption]<img src="" alt="" />This is an image caption[/caption] My second paragraph.</p>
<p>My third paragraph.</p>
Caption Filter borks replacement of the caption:
<p>My first paragraph.</p>
<div class="caption-inner">
<img alt="" src="" />
This is an image caption
</div>
My second paragraph.</p>
<p>My third paragraph.</p>
Note the missing opening p tag for the second paragraph. The problem lies in Drupal.captionFilter.toHTML(). The regex includes the opening paragraph tag in co.replace()
, but doesn't include it in the replacement.
Comment | File | Size | Author |
---|---|---|---|
#5 | 1967242-5-caption-filter-p.patch | 1.32 KB | theunraveler |
#4 | 1967242-4-caption-filter-p.patch | 1.3 KB | dalin |
Comments
Comment #1
kmontyCan you give me steps to reproduce? I'm not even certain what editor you are using...
Comment #2
dalinckeditor + caption filter + media module (though I don't *think* that matters).
Reproduction steps are very straightforward:
1) Create some paragraphs.
2) Insert an image at the beginning of paragraph #2.
3) Add a caption.
4) Save the form.
It looks to be a straightforward fix. I'll take a stab at it tomorrow.
Comment #3
dalinI'm guessing that looking at that regex that tinymce might do things slightly different - I bet it wraps the image in a dedicated p tag, rather than allowing it to be within one of the existing paragraphs.
Comment #4
dalinThis relies on
https://drupal.org/node/696734#comment-7192676
since it seems to only apply to CKEditor.
Perhaps this should be rolled back into the other ticket :-P
Comment #5
theunraveler CreditAttribution: theunraveler commentedThe previous patch seem to introduce a bug that inserts a "undefined" string into the WYSIWYG contents whenever the WYSIWYG is disabled, the re-enabled (using the "Disable rich-text" link provides by the WYSIWYG module).
Here's a patch that fixes that.
Comment #6
kmontyThe work on this issue should be done within the main #696734: Integration with CKEditor or WYSIWYG? issue.