Make WordPress Core

Changeset 29429


Ignore:
Timestamp:
08/07/2014 05:52:03 AM (12 years ago)
Author:
wonderboymusic
Message:

MediaElement upgrade: cleanup for generated markup for videos.

See #29110.

Location:
trunk/src/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media-template.php

    r29416 r29429  
    5151    $video_types = wp_get_video_extensions();
    5252?>
    53 <#  var w, h, settings = wp.media.view.settings,
     53<#  var w_rule = '', h_rule = '',
     54        w, h, settings = wp.media.view.settings,
    5455        isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/);
    5556
     
    6566        h = data.model.height;
    6667    }
     68
     69    if ( w ) {
     70        w_rule = ' width: ' + w + 'px;';
     71    }
     72
     73    if ( h ) {
     74        h_rule = ' height: ' + h + 'px;';
     75    }
    6776#>
    68 <div style="max-width: 100%; width: {{ w }}px">
     77<div style="max-width: 100%;{{ w_rule }}{{ h_rule }}">
    6978<video controls
    7079    class="wp-video-shortcode{{ isYouTube ? ' youtube-video' : '' }}"
    71     width="{{ w }}"
    72     height="{{ h }}"
     80    <# if ( w ) { #>width="{{ w }}"<# } #>
     81    <# if ( h ) { #>height="{{ h }}"<# } #>
    7382    <?php
    7483    $props = array( 'poster' => '', 'preload' => 'metadata' );
     
    281290                    </audio>
    282291                </div>
    283                 <# } else if ( 'video' === data.type ) { #>
    284                 <div style="max-width: 100%; width: {{ data.width }}px" class="wp-media-wrapper">
     292                <# } else if ( 'video' === data.type ) {
     293                    var w_rule = h_rule = '';
     294                    if ( data.width ) {
     295                        w_rule = ' width: ' + data.width + 'px;';
     296                    } else if ( wp.media.view.settings.contentWidth ) {
     297                        w_rule = ' width: ' + wp.media.view.settings.contentWidth + 'px;';
     298                    }
     299                    if ( data.height ) {
     300                        h_rule = ' height: ' + data.height + 'px;';
     301                    }
     302                #>
     303                <div style="max-width: 100%; {{ w_rule }}{{ h_rule }}" class="wp-media-wrapper">
    285304                    <video controls class="wp-video-shortcode" preload="metadata"
    286                         width="{{ data.width }}" height="{{ data.height }}"
     305                        <# if ( data.width ) { #>width="{{ data.width }}"<# } #>
     306                        <# if ( data.height ) { #>height="{{ data.height }}"<# } #>
    287307                        <# if ( data.image && data.image.src !== data.icon ) { #>poster="{{ data.image.src }}"<# } #>>
    288308                        <source type="{{ data.mime }}" src="{{ data.url }}"/>
  • trunk/src/wp-includes/media.php

    r29428 r29429  
    18751875    $html .= '</video>';
    18761876
    1877     $output = sprintf( '<div style="width: %dpx; max-width: 100%%;" class="wp-video">%s</div>', $atts['width'], $html );
     1877    $width_rule = $height_rule = '';
     1878    if ( ! empty( $atts['width'] ) ) {
     1879        $width_rule = sprintf( ' width: %dpx;', $atts['width'] );
     1880    }
     1881    if ( ! empty( $atts['height'] ) ) {
     1882        $height_rule = sprintf( ' height: %dpx;', $atts['height'] );
     1883    }
     1884    $output = sprintf( '<div style="max-width: 100%%;%s%s" class="wp-video">%s</div>', $width_rule, $height_rule, $html );
    18781885
    18791886    /**
  • trunk/src/wp-includes/post-template.php

    r29235 r29429  
    15211521            $atts['height'] = (int) $meta['height'];
    15221522        }
     1523        if ( has_post_thumbnail() ) {
     1524            $atts['poster'] = wp_get_attachment_url( get_post_thumbnail_id() );
     1525        }
    15231526        $p = wp_video_shortcode( $atts );
    15241527    } elseif ( 0 === strpos( $post->post_mime_type, 'audio' ) ) {
Note: See TracChangeset for help on using the changeset viewer.