Media: Always add alt
attributes to images inserted from URLs
Previously, when inserting an image from a URL, leaving the `alt` field blank in the media modal would result in an image being inserted into the editor without an `alt` attribute, rather than an empty `alt`. This happened because the `props.type` would not get set in `wp.media.string.props()` — because `attachment` is undefined in this case — causing the image fallbacks to get skipped. This fixes the issue by explicitly setting `props.type` to 'image' in `wp.media.string.image()` before filling out the rest of the properties. Props ambrosey, dabnpits. Fixes #36735. git-svn-id: https://develop.svn.wordpress.org/trunk@38065 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f24f22ce4c
commit
9d0f2e27d0
@ -55,7 +55,14 @@
|
||||
fallbacks = function( props ) {
|
||||
// Generate alt fallbacks and strip tags.
|
||||
if ( 'image' === props.type && ! props.alt ) {
|
||||
props.alt = props.caption || props.title || '';
|
||||
if ( props.caption ) {
|
||||
props.alt = props.caption;
|
||||
} else if ( props.title !== props.url ) {
|
||||
props.alt = props.title;
|
||||
} else {
|
||||
props.alt = '';
|
||||
}
|
||||
|
||||
props.alt = props.alt.replace( /<\/?[^>]+>/g, '' );
|
||||
props.alt = props.alt.replace( /[\r\n]+/g, ' ' );
|
||||
}
|
||||
@ -233,6 +240,7 @@
|
||||
var img = {},
|
||||
options, classes, shortcode, html;
|
||||
|
||||
props.type = 'image';
|
||||
props = wp.media.string.props( props, attachment );
|
||||
classes = props.classes || [];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user