[wp-trac] [WordPress Trac] #39912: Image empty alt attributes get stripped out when editing the image details from a post

WordPress Trac noreply at wordpress.org
Sat Feb 18 20:47:29 UTC 2017


#39912: Image empty alt attributes get stripped out when editing the image details
from a post
--------------------------+------------------------------
 Reporter:  afercia       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  high          |   Milestone:  Awaiting Review
Component:  TinyMCE       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:  accessibility
--------------------------+------------------------------
Changes (by afercia):

 * component:  Media => TinyMCE


Comment:

 I think it's because the `wpeditimage` TinyMCE plugin uses
 `tinymce.dom.DOMUtils.setAttribs` which just recursively calls
 `tinymce.dom.DOMUtils.setAttrib` which accepts 3 params, and the ` one:
 > Value to set on the attribute - if this value is falsy like null, 0 or
 '' it will remove the attribute instead.

 So when `wp.media` passes an empty alt attribute, TinyMCE just strips it
 out. It makes sense to remove empty HTML attributes, with the notable
 exception of the `alt` attribute. While WordPress should ensure this
 doesn't happen and try to find a way to re-add the empty alt attribute
 when appropriate, maybe this should be reported upstream too.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39912#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list