Make WordPress Core


Ignore:
Timestamp:
02/28/2014 09:27:40 PM (11 years ago)
Author:
wonderboymusic
Message:
  • Videos should always render at the same aspect ratio.
  • Don't force a pseudo-mime-type for .m4v files
  • Uniformly adapt to $content_width when setting video dimensions on the front end
  • Add the height attribute to the initial <video> in the video playlist JS template
  • Add some defensive/responsive CSS for a/v on the Edit Media page

See #27243.

File:
1 edited

Legend:

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

    r27320 r27328  
    10591059
    10601060    $outer = 22; // default padding and border of wrapper
     1061
     1062    $default_width = 640;
     1063    $default_height = 360;
     1064
    10611065    $theme_width = $content_width - $outer;
     1066    $theme_height = round( ( $default_height * $theme_width ) / $default_width );
     1067
    10621068    $data = compact( 'type', 'style' );
    10631069
     
    10911097
    10921098            if ( 'video' === $type ) {
    1093                 $width = empty( $meta['width'] ) ? 640 : $meta['width'];
    1094                 $height = empty( $meta['height'] ) ? 360 : $meta['height'];
    1095                 $theme_height = round( ( $height * $theme_width ) / $width );
     1099                if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
     1100                    $width = $meta['width'];
     1101                    $height = $meta['height'];
     1102                    $theme_height = round( ( $height * $theme_width ) / $width );
     1103                } else {
     1104                    $width = $default_width;
     1105                    $height = $default_height;
     1106                }
     1107
    10961108                $track['dimensions'] = array(
    10971109                    'original' => compact( 'width', 'height' ),
     
    11661178    <div class="wp-playlist-current-item"></div>
    11671179    <?php endif ?>
    1168     <<?php echo $safe_type ?> controls="controls" preload="metadata" width="<?php echo (int) $theme_width ?>"></<?php echo $safe_type ?>>
     1180    <<?php echo $safe_type ?> controls="controls" preload="metadata" width="<?php
     1181        echo (int) $theme_width;
     1182    ?>"<?php if ( 'video' === $safe_type ):
     1183        echo ' height="', (int) $theme_height, '"';
     1184    endif; ?>></<?php echo $safe_type ?>>
    11691185    <div class="wp-playlist-next"></div>
    11701186    <div class="wp-playlist-prev"></div>
     
    14451461        'autoplay' => '',
    14461462        'preload'  => 'metadata',
     1463        'width'    => 640,
    14471464        'height'   => 360,
    1448         'width'    => empty( $content_width ) ? 640 : $content_width,
    14491465    );
    14501466
     
    14551471    extract( $atts );
    14561472
    1457     $w = $width;
    1458     $h = $height;
    1459     if ( is_admin() && $width > 600 )
    1460         $w = 600;
    1461     elseif ( ! is_admin() && $w > $defaults_atts['width'] )
    1462         $w = $defaults_atts['width'];
    1463 
    1464     if ( $w < $width )
    1465         $height = round( ( $h * $w ) / $width );
    1466 
    1467     $width = $w;
     1473    if ( is_admin() ) {
     1474        // shrink the video so it isn't huge in the admin
     1475        if ( $width > $defaults_atts['width'] ) {
     1476            $height = round( ( $height * $defaults_atts['width'] ) / $width );
     1477            $width = $defaults_atts['width'];
     1478        }
     1479    } else {
     1480        // if the video is bigger than the theme
     1481        if ( $width > $content_width ) {
     1482            $height = round( ( $height * $content_width ) / $width );
     1483            $width = $content_width;
     1484        }
     1485    }
    14681486
    14691487    $yt_pattern = '#^https?://(:?www\.)?(:?youtube\.com/watch|youtu\.be/)#';
     
    15461564            } else {
    15471565                $type = wp_check_filetype( $$fallback, wp_get_mime_types() );
    1548                 // m4v sometimes shows up as video/mpeg which collides with mp4
    1549                 if ( 'm4v' === $type['ext'] )
    1550                     $type['type'] = 'video/m4v';
    15511566            }
    15521567            $html .= sprintf( $source, $type['type'], esc_url( $$fallback ) );
Note: See TracChangeset for help on using the changeset viewer.