Make WordPress Core

Changeset 23989


Ignore:
Timestamp:
04/14/2013 04:43:26 PM (12 years ago)
Author:
markjaquith
Message:

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

props wonderboymusic. fixes #23955.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/post-formats.js

    r23969 r23989  
    112112
    113113            mediaPreview = function (attachment) {
    114                 var dimensions = '', url = attachment.url,
     114                var w, h, dimensions = '', url = attachment.url,
    115115                    mime = attachment.mime,
    116116                    format = attachment.type;
    117117
    118118                if ( 'video' === format ) {
    119                     if ( attachment.width )
    120                         dimensions += ' width="' + attachment.width + '"';
    121                     if ( attachment.height )
    122                         dimensions += ' height="' + attachment.height + '"';
     119                    if ( attachment.width ) {
     120                        w = attachment.width;
     121                        if ( w > 600 )
     122                            w = 600;
     123                        dimensions += ' width="' + w + '"';
     124                    }
     125
     126                    if ( attachment.height ) {
     127                        h = attachment.height;
     128                        if ( attachment.width && w < attachment.width )
     129                            h = Math.round( ( h * w ) / attachment.width );
     130                        dimensions += ' height="' + h + '"';
     131                    }
    123132                }
    124133
  • trunk/wp-content/themes/twentythirteen/functions.php

    r23972 r23989  
    548548 */
    549549function twentythirteen_video_width( $atts ) {
    550     if ( has_post_format( 'video' ) )
    551         $atts['width'] = 724;
     550    if ( ! is_admin() && has_post_format( 'video' ) ) {
     551        $new_width = 724;
     552        $atts['height'] = round( ( $atts['height'] * $new_width ) / $atts['width'] );
     553        $atts['width'] = $new_width;
     554    }
    552555
    553556    return $atts;
  • trunk/wp-includes/media.php

    r23988 r23989  
    957957        'width' => empty( $content_width ) ? 640 : $content_width,
    958958    );
     959
    959960    foreach ( $default_types as $type  )
    960961        $defaults_atts[$type] = '';
     
    962963    $atts = shortcode_atts( $defaults_atts, $attr, 'video' );
    963964    extract( $atts );
     965
     966    $w = $width;
     967    $h = $height;
     968    if ( is_admin() && $width > 600 )
     969        $w = 600;
     970    elseif ( ! is_admin() && $w > $defaults_atts['width'] )
     971        $w = $defaults_atts['width'];
     972
     973    if ( $w < $width )
     974        $height = round( ( $h * $w ) / $width );
     975
     976    $width = $w;
    964977
    965978    $primary = false;
Note: See TracChangeset for help on using the changeset viewer.