Ticket #18984: 18984.5.diff

File 18984.5.diff, 1.6 KB (added by koopersmith, 6 months ago)
  • wp-includes/js/media-editor.js

     
    99                // outputting the proper object format based on the 
    1010                // attachment's type. 
    1111                props: function( props, attachment ) { 
    12                         var link, linkUrl, size, sizes; 
     12                        var link, linkUrl, size, sizes, fallbacks; 
    1313 
     14                        // Final fallbacks run after all processing has been completed. 
     15                        fallbacks = function( props ) { 
     16                                // Generate alt fallbacks and strip tags. 
     17                                if ( 'image' === props.type && ! props.alt ) { 
     18                                        props.alt = props.caption || props.title || ''; 
     19                                        props.alt = props.alt.replace( /<\/?[^>]+>/g, '' ); 
     20                                } 
     21 
     22                                return props; 
     23                        }; 
     24 
    1425                        props = props ? _.clone( props ) : {}; 
    1526 
    1627                        if ( attachment && attachment.type ) 
     
    2738 
    2839                        // All attachment-specific settings follow. 
    2940                        if ( ! attachment ) 
    30                                 return props; 
     41                                return fallbacks( props ); 
    3142 
     43                        props.title = props.title || attachment.title; 
     44 
    3245                        link = props.link || getUserSetting( 'urlbutton', 'post' ); 
    3346                        if ( 'file' === link ) 
    3447                                linkUrl = attachment.url; 
     
    5467 
    5568                        // Format properties for non-images. 
    5669                        } else { 
    57                                 _.extend( props, { 
    58                                         title:   attachment.title || attachment.filename, 
    59                                         rel:     'attachment wp-att-' + attachment.id 
    60                                 }); 
     70                                props.title = props.title || attachment.filename; 
     71                                props.rel = props.rel || 'attachment wp-att-' + attachment.id; 
    6172                        } 
    6273 
    63                         return props; 
     74                        return fallbacks( props ); 
    6475                }, 
    6576 
    6677                link: function( props, attachment ) {