<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[27328] trunk/src: * Videos should always render at the same aspect ratio.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/27328">27328</a></dd>
<dt>Author</dt> <dd>wonderboymusic</dd>
<dt>Date</dt> <dd>2014-02-28 21:27:40 +0000 (Fri, 28 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>* 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 <a href="http://core.trac.wordpress.org/ticket/27243">#27243</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincssmediacss">trunk/src/wp-admin/css/media.css</a></li>
<li><a href="#trunksrcwpadminincludesmediaphp">trunk/src/wp-admin/includes/media.php</a></li>
<li><a href="#trunksrcwpincludesmediaphp">trunk/src/wp-includes/media.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincssmediacss"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/css/media.css (27327 => 27328)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/css/media.css 2014-02-28 20:54:05 UTC (rev 27327)
+++ trunk/src/wp-admin/css/media.css    2014-02-28 21:27:40 UTC (rev 27328)
</span><span class="lines">@@ -640,6 +640,15 @@
</span><span class="cx">  padding: 2px 10px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+audio, video {
+       display: inline-block;
+       max-width: 100%;
+}
+
+.mejs-container {
+       width: 100%;
+}
+
</ins><span class="cx"> /* =Media Queries
</span><span class="cx"> -------------------------------------------------------------- */
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunksrcwpadminincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/includes/media.php (27327 => 27328)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/includes/media.php    2014-02-28 20:54:05 UTC (rev 27327)
+++ trunk/src/wp-admin/includes/media.php       2014-02-28 21:27:40 UTC (rev 27328)
</span><span class="lines">@@ -2640,20 +2640,17 @@
</span><span class="cx">          maybe_regenerate_attachment_metadata( $post );
</span><span class="cx"> 
</span><span class="cx">          $meta = wp_get_attachment_metadata( $attachment_id );
</span><del>-               $w = ! empty( $meta['width'] ) ? min( $meta['width'], 600 ) : 0;
-               $h = 0;
-               if ( ! empty( $meta['height'] ) )
-                       $h = $meta['height'];
-               if ( $h && $w < $meta['width'] )
</del><ins>+                $w = ! empty( $meta['width'] ) ? min( $meta['width'], 640 ) : 0;
+               $h = ! empty( $meta['height'] ) ? $meta['height'] : 0;
+               if ( $h && $w < $meta['width'] ) {
</ins><span class="cx">                   $h = round( ( $meta['height'] * $w ) / $meta['width'] );
</span><ins>+               }
</ins><span class="cx"> 
</span><span class="cx">          $attr = array( 'src' => $att_url );
</span><del>-
-               if ( ! empty( $meta['width' ] ) )
</del><ins>+                if ( ! empty( $w ) && ! empty( $h ) ) {
</ins><span class="cx">                   $attr['width'] = $w;
</span><del>-
-               if ( ! empty( $meta['height'] ) )
</del><span class="cx">                   $attr['height'] = $h;
</span><ins>+               }
</ins><span class="cx"> 
</span><span class="cx">          echo wp_video_shortcode( $attr );
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunksrcwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/media.php (27327 => 27328)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/media.php  2014-02-28 20:54:05 UTC (rev 27327)
+++ trunk/src/wp-includes/media.php     2014-02-28 21:27:40 UTC (rev 27328)
</span><span class="lines">@@ -1058,7 +1058,13 @@
</span><span class="cx">          || $images;
</span><span class="cx"> 
</span><span class="cx">  $outer = 22; // default padding and border of wrapper
</span><ins>+
+       $default_width = 640;
+       $default_height = 360;
+
</ins><span class="cx">   $theme_width = $content_width - $outer;
</span><ins>+       $theme_height = round( ( $default_height * $theme_width ) / $default_width );
+
</ins><span class="cx">   $data = compact( 'type', 'style' );
</span><span class="cx"> 
</span><span class="cx">  // don't pass strings to JSON, will be truthy in JS
</span><span class="lines">@@ -1090,9 +1096,15 @@
</span><span class="cx">                  }
</span><span class="cx"> 
</span><span class="cx">                  if ( 'video' === $type ) {
</span><del>-                               $width = empty( $meta['width'] ) ? 640 : $meta['width'];
-                               $height = empty( $meta['height'] ) ? 360 : $meta['height'];
-                               $theme_height = round( ( $height * $theme_width ) / $width );
</del><ins>+                                if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
+                                       $width = $meta['width'];
+                                       $height = $meta['height'];
+                                       $theme_height = round( ( $height * $theme_width ) / $width );
+                               } else {
+                                       $width = $default_width;
+                                       $height = $default_height;
+                               }
+
</ins><span class="cx">                           $track['dimensions'] = array(
</span><span class="cx">                                  'original' => compact( 'width', 'height' ),
</span><span class="cx">                                  'resized' => array(
</span><span class="lines">@@ -1165,7 +1177,11 @@
</span><span class="cx">  <?php if ( 'audio' === $type ): ?>
</span><span class="cx">  <div class="wp-playlist-current-item"></div>
</span><span class="cx">  <?php endif ?>
</span><del>-       <<?php echo $safe_type ?> controls="controls" preload="metadata" width="<?php echo (int) $theme_width ?>"></<?php echo $safe_type ?>>
</del><ins>+        <<?php echo $safe_type ?> controls="controls" preload="metadata" width="<?php
+               echo (int) $theme_width;
+       ?>"<?php if ( 'video' === $safe_type ):
+               echo ' height="', (int) $theme_height, '"';
+       endif; ?>></<?php echo $safe_type ?>>
</ins><span class="cx">   <div class="wp-playlist-next"></div>
</span><span class="cx">  <div class="wp-playlist-prev"></div>
</span><span class="cx">  <noscript>
</span><span class="lines">@@ -1444,8 +1460,8 @@
</span><span class="cx">          'loop'     => '',
</span><span class="cx">          'autoplay' => '',
</span><span class="cx">          'preload'  => 'metadata',
</span><ins>+               'width'    => 640,
</ins><span class="cx">           'height'   => 360,
</span><del>-               'width'    => empty( $content_width ) ? 640 : $content_width,
</del><span class="cx">   );
</span><span class="cx"> 
</span><span class="cx">  foreach ( $default_types as $type )
</span><span class="lines">@@ -1454,18 +1470,20 @@
</span><span class="cx">  $atts = shortcode_atts( $defaults_atts, $attr, 'video' );
</span><span class="cx">  extract( $atts );
</span><span class="cx"> 
</span><del>-       $w = $width;
-       $h = $height;
-       if ( is_admin() && $width > 600 )
-               $w = 600;
-       elseif ( ! is_admin() && $w > $defaults_atts['width'] )
-               $w = $defaults_atts['width'];
</del><ins>+        if ( is_admin() ) {
+               // shrink the video so it isn't huge in the admin
+               if ( $width > $defaults_atts['width'] ) {
+                       $height = round( ( $height * $defaults_atts['width'] ) / $width );
+                       $width = $defaults_atts['width'];
+               }
+       } else {
+               // if the video is bigger than the theme
+               if ( $width > $content_width ) {
+                       $height = round( ( $height * $content_width ) / $width );
+                       $width = $content_width;
+               }
+       }
</ins><span class="cx"> 
</span><del>-       if ( $w < $width )
-               $height = round( ( $h * $w ) / $width );
-
-       $width = $w;
-
</del><span class="cx">   $yt_pattern = '#^https?://(:?www\.)?(:?youtube\.com/watch|youtu\.be/)#';
</span><span class="cx"> 
</span><span class="cx">  $primary = false;
</span><span class="lines">@@ -1545,9 +1563,6 @@
</span><span class="cx">                          $type = array( 'type' => 'video/youtube' );
</span><span class="cx">                  } else {
</span><span class="cx">                          $type = wp_check_filetype( $$fallback, wp_get_mime_types() );
</span><del>-                               // m4v sometimes shows up as video/mpeg which collides with mp4
-                               if ( 'm4v' === $type['ext'] )
-                                       $type['type'] = 'video/m4v';
</del><span class="cx">                   }
</span><span class="cx">                  $html .= sprintf( $source, $type['type'], esc_url( $$fallback ) );
</span><span class="cx">          }
</span></span></pre>
</div>
</div>

</body>
</html>