Constrain large videos from rendering bigger than $content_width on both frontend and backend.

props wonderboymusic. fixes #23955.

git-svn-id: http://core.svn.wordpress.org/trunk@23989 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Mark Jaquith 2013-04-14 16:43:26 +00:00
parent f715505934
commit de45c749df
3 changed files with 32 additions and 7 deletions

View File

@ -111,15 +111,24 @@ window.wp = window.wp || {};
}); });
mediaPreview = function (attachment) { mediaPreview = function (attachment) {
var dimensions = '', url = attachment.url, var w, h, dimensions = '', url = attachment.url,
mime = attachment.mime, mime = attachment.mime,
format = attachment.type; format = attachment.type;
if ( 'video' === format ) { if ( 'video' === format ) {
if ( attachment.width ) if ( attachment.width ) {
dimensions += ' width="' + attachment.width + '"'; w = attachment.width;
if ( attachment.height ) if ( w > 600 )
dimensions += ' height="' + attachment.height + '"'; 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(); $('#' + format + '-preview').remove();

View File

@ -547,8 +547,11 @@ add_action( 'template_redirect', 'twentythirteen_content_width' );
* @return array Filtered attribute list. * @return array Filtered attribute list.
*/ */
function twentythirteen_video_width( $atts ) { function twentythirteen_video_width( $atts ) {
if ( has_post_format( 'video' ) ) if ( ! is_admin() && has_post_format( 'video' ) ) {
$atts['width'] = 724; $new_width = 724;
$atts['height'] = round( ( $atts['height'] * $new_width ) / $atts['width'] );
$atts['width'] = $new_width;
}
return $atts; return $atts;
} }

View File

@ -956,12 +956,25 @@ function wp_video_shortcode( $attr ) {
'height' => 360, 'height' => 360,
'width' => empty( $content_width ) ? 640 : $content_width, 'width' => empty( $content_width ) ? 640 : $content_width,
); );
foreach ( $default_types as $type ) foreach ( $default_types as $type )
$defaults_atts[$type] = ''; $defaults_atts[$type] = '';
$atts = shortcode_atts( $defaults_atts, $attr, 'video' ); $atts = shortcode_atts( $defaults_atts, $attr, 'video' );
extract( $atts ); 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; $primary = false;
if ( ! empty( $src ) ) { if ( ! empty( $src ) ) {
$type = wp_check_filetype( $src ); $type = wp_check_filetype( $src );