[wp-trac] [WordPress Trac] #27195: Disappearing image captions on pasted images from Google Docs

WordPress Trac noreply at wordpress.org
Mon Feb 24 11:22:57 UTC 2014


#27195: Disappearing image captions on pasted images from Google Docs
-----------------------------+-----------------------------
 Reporter:  TobiasKjrsgaard  |      Owner:
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Media            |    Version:  3.8.1
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 When you paste an image from Google Docs the width and height attributes
 in the resulting <img> tag contains the three characters "px;" at the end
 as shown below:
 {{{
 <img alt="" src"(…)" width="200px;" height="150px;">
 }}}

 Having these three extra chars in the attribute fields somehow makes the
 filter that adds image captions fail. Whenever I try adding captions they
 turn up fine in the TinyMCE editor, but as soon as the post is published
 the caption is stripped from the string and I'm left with the original
 <img> tag.

 I suspect that a solution could be a minor modification to
 image_add_caption() function i media.php - specifically the lines posted
 below. However, I'm not confident that my skills are adequate enough to
 implement this fix.

 {{{
 if ( ! preg_match( '/width=["\']([0-9]+)/', $html, $matches ) )
         return $html;
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27195>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list