In the add media modal, fallback back to caption if alt is not set. Falback to title if neither caption nor alt are set.
Props koopersmith see #18984 git-svn-id: http://core.svn.wordpress.org/trunk@22937 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
459edbd5f6
commit
fccd72a74b
|
@ -9,7 +9,18 @@
|
||||||
// outputting the proper object format based on the
|
// outputting the proper object format based on the
|
||||||
// attachment's type.
|
// attachment's type.
|
||||||
props: function( props, attachment ) {
|
props: function( props, attachment ) {
|
||||||
var link, linkUrl, size, sizes;
|
var link, linkUrl, size, sizes, fallbacks;
|
||||||
|
|
||||||
|
// Final fallbacks run after all processing has been completed.
|
||||||
|
fallbacks = function( props ) {
|
||||||
|
// Generate alt fallbacks and strip tags.
|
||||||
|
if ( 'image' === props.type && ! props.alt ) {
|
||||||
|
props.alt = props.caption || props.title || '';
|
||||||
|
props.alt = props.alt.replace( /<\/?[^>]+>/g, '' );
|
||||||
|
}
|
||||||
|
|
||||||
|
return props;
|
||||||
|
};
|
||||||
|
|
||||||
props = props ? _.clone( props ) : {};
|
props = props ? _.clone( props ) : {};
|
||||||
|
|
||||||
|
@ -27,7 +38,9 @@
|
||||||
|
|
||||||
// All attachment-specific settings follow.
|
// All attachment-specific settings follow.
|
||||||
if ( ! attachment )
|
if ( ! attachment )
|
||||||
return props;
|
return fallbacks( props );
|
||||||
|
|
||||||
|
props.title = props.title || attachment.title;
|
||||||
|
|
||||||
link = props.link || getUserSetting( 'urlbutton', 'post' );
|
link = props.link || getUserSetting( 'urlbutton', 'post' );
|
||||||
if ( 'file' === link )
|
if ( 'file' === link )
|
||||||
|
@ -54,13 +67,11 @@
|
||||||
|
|
||||||
// Format properties for non-images.
|
// Format properties for non-images.
|
||||||
} else {
|
} else {
|
||||||
_.extend( props, {
|
props.title = props.title || attachment.filename;
|
||||||
title: attachment.title || attachment.filename,
|
props.rel = props.rel || 'attachment wp-att-' + attachment.id;
|
||||||
rel: 'attachment wp-att-' + attachment.id
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return props;
|
return fallbacks( props );
|
||||||
},
|
},
|
||||||
|
|
||||||
link: function( props, attachment ) {
|
link: function( props, attachment ) {
|
||||||
|
|
Loading…
Reference in New Issue