Make WordPress Core


Ignore:
Timestamp:
03/22/2014 11:25:08 PM (13 years ago)
Author:
wonderboymusic
Message:

General code cleanup and improving video sizing in the admin:

  • Abstract the setting of a primary button and its callback in wp.media.view.MediaFrame.MediaDetails
  • Account for the existence or non-existence of $content_width in the TinyMCE views for video
  • Make sure video models always have dimensions, even if they are the defaults
  • For browsers that are not Firefox, don't use a timeout when setting the MediaElementPlayer instance in TinyMCE views

See #27320.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media-template.php

    r27645 r27655  
    4949        $video_types = wp_get_video_extensions();
    5050?>
    51 <#
    52 var isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/);
    53         w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width,
    54         h = ! data.model.height ? 360 : data.model.height;
    55 
    56 if ( data.model.width && w !== data.model.width ) {
    57         h = Math.ceil( ( h * w ) / data.model.width );
    58 }
     51<#  var w, h, settings = wp.media.view.settings,
     52                isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/);
     53
     54        if ( settings.contentWidth && data.model.width >= settings.contentWidth ) {
     55                w = settings.contentWidth;
     56        } else {
     57                w = data.model.width;
     58        }
     59
     60        if ( w !== data.model.width ) {
     61                h = Math.ceil( ( h * w ) / data.model.width );
     62        } else {
     63                h = data.model.height;
     64        }
    5965#>
    6066<div style="max-width: 100%; width: {{ w }}px">
    … …  
    8692                <source src="{{ data.model.src }}" type="video/youtube" />
    8793                <# } else { #>
    88                 <source src="{{ data.model.src }}" type="{{ wp.media.view.settings.embedMimes[ data.model.src.split('.').pop() ] }}" />
     94                <source src="{{ data.model.src }}" type="{{ settings.embedMimes[ data.model.src.split('.').pop() ] }}" />
    8995                <# }
    9096        } #>
    … …  
    9298        <?php foreach ( $video_types as $type ):
    9399        ?><# if ( data.model.<?php echo $type ?> ) { #>
    94         <source src="{{ data.model.<?php echo $type ?> }}" type="{{ wp.media.view.settings.embedMimes[ '<?php echo $type ?>' ] }}" />
     100        <source src="{{ data.model.<?php echo $type ?> }}" type="{{ settings.embedMimes[ '<?php echo $type ?>' ] }}" />
    95101        <# } #>
    96102        <?php endforeach; ?>
Note: See TracChangeset for help on using the changeset viewer.