Make WordPress Core

Changeset 24784


Ignore:
Timestamp:
07/23/2013 05:29:55 PM (12 years ago)
Author:
nacin
Message:

Media: Fix embedding of audio/video players when the file was just uploaded.

While uploading, we know an attachment's filename but not its mime type. Check specifically for extensions. Check for type as a convenience when it is available.

fixes #24449.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/media-views.js

    r24777 r24784  
    463463
    464464        canEmbed: function( attachment ) {
    465             var type = attachment.get('type');
    466             if ( type !== 'audio' && type !== 'video' )
    467                 return false;
     465            // If uploading, we know the filename but not the mime type.
     466            if ( ! attachment.get('uploading') ) {
     467                var type = attachment.get('type');
     468                if ( type !== 'audio' && type !== 'video' )
     469                    return false;
     470            }
    468471
    469472            return _.contains( media.view.settings.embedExts, attachment.get('filename').split('.').pop() );
  • trunk/wp-includes/media-template.php

    r24777 r24784  
    298298                    <# } #>>
    299299
    300                 <# if ( data.model.canEmbed && 'audio' === data.type ) { #>
     300                <# if ( data.model.canEmbed ) { #>
    301301                    <option value="embed" selected>
    302                         <?php esc_attr_e('Embed Audio Player'); ?>
    303                     </option>
    304                     <option value="file">
    305                 <# } else if ( data.model.canEmbed && 'video' === data.type ) { #>
    306                     <option value="embed" selected>
    307                         <?php esc_attr_e('Embed Video Player'); ?>
     302                        <?php esc_attr_e('Embed Media Player'); ?>
    308303                    </option>
    309304                    <option value="file">
Note: See TracChangeset for help on using the changeset viewer.