diff --git a/wp-admin/js/post-formats.js b/wp-admin/js/post-formats.js index 10aab6174e..62c75f6642 100644 --- a/wp-admin/js/post-formats.js +++ b/wp-admin/js/post-formats.js @@ -111,15 +111,24 @@ window.wp = window.wp || {}; }); mediaPreview = function (attachment) { - var dimensions = '', url = attachment.url, + var w, h, dimensions = '', url = attachment.url, mime = attachment.mime, format = attachment.type; if ( 'video' === format ) { - if ( attachment.width ) - dimensions += ' width="' + attachment.width + '"'; - if ( attachment.height ) - dimensions += ' height="' + attachment.height + '"'; + if ( attachment.width ) { + w = attachment.width; + if ( w > 600 ) + w = 600; + dimensions += ' width="' + w + '"'; + } + + if ( attachment.height ) { + h = attachment.height; + if ( attachment.width && w < attachment.width ) + h = Math.round( ( h * w ) / attachment.width ); + dimensions += ' height="' + h + '"'; + } } $('#' + format + '-preview').remove(); diff --git a/wp-content/themes/twentythirteen/functions.php b/wp-content/themes/twentythirteen/functions.php index b9e588af47..03fffcc096 100644 --- a/wp-content/themes/twentythirteen/functions.php +++ b/wp-content/themes/twentythirteen/functions.php @@ -547,8 +547,11 @@ add_action( 'template_redirect', 'twentythirteen_content_width' ); * @return array Filtered attribute list. */ function twentythirteen_video_width( $atts ) { - if ( has_post_format( 'video' ) ) - $atts['width'] = 724; + if ( ! is_admin() && has_post_format( 'video' ) ) { + $new_width = 724; + $atts['height'] = round( ( $atts['height'] * $new_width ) / $atts['width'] ); + $atts['width'] = $new_width; + } return $atts; } diff --git a/wp-includes/media.php b/wp-includes/media.php index aa52352055..e626f54817 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -956,12 +956,25 @@ function wp_video_shortcode( $attr ) { 'height' => 360, 'width' => empty( $content_width ) ? 640 : $content_width, ); + foreach ( $default_types as $type ) $defaults_atts[$type] = ''; $atts = shortcode_atts( $defaults_atts, $attr, 'video' ); extract( $atts ); + $w = $width; + $h = $height; + if ( is_admin() && $width > 600 ) + $w = 600; + elseif ( ! is_admin() && $w > $defaults_atts['width'] ) + $w = $defaults_atts['width']; + + if ( $w < $width ) + $height = round( ( $h * $w ) / $width ); + + $width = $w; + $primary = false; if ( ! empty( $src ) ) { $type = wp_check_filetype( $src );