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:
parent
f715505934
commit
de45c749df
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue