X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/888fa4ed68091f3314f711c5f6fe75858bf5410b..e0feb3b2e5b436a06bbb04fbc838d1cd6ec95399:/wp-includes/media-template.php diff --git a/wp-includes/media-template.php b/wp-includes/media-template.php index 25354618..8edeb62e 100644 --- a/wp-includes/media-template.php +++ b/wp-includes/media-template.php @@ -50,8 +50,14 @@ function wp_underscore_audio_template() { function wp_underscore_video_template() { $video_types = wp_get_video_extensions(); ?> -<# var w, h, settings = wp.media.view.settings, - isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/); +<# var w_rule = h_rule = '', classes = [], + w, h, settings = wp.media.view.settings, + isYouTube = isVimeo = false; + + if ( ! _.isEmpty( data.model.src ) ) { + isYouTube = data.model.src.match(/youtube|youtu\.be/); + isVimeo = -1 !== data.model.src.indexOf('vimeo'); + } if ( settings.contentWidth && data.model.width >= settings.contentWidth ) { w = settings.contentWidth; @@ -60,16 +66,32 @@ function wp_underscore_video_template() { } if ( w !== data.model.width ) { - h = Math.ceil( ( h * w ) / data.model.width ); + h = Math.ceil( ( data.model.height * w ) / data.model.width ); } else { h = data.model.height; } + + if ( w ) { + w_rule = 'width: ' + w + 'px; '; + } + if ( h ) { + h_rule = 'height: ' + h + 'px;'; + } + + if ( isYouTube ) { + classes.push( 'youtube-video' ); + } + + if ( isVimeo ) { + classes.push( 'vimeo-video' ); + } + #> -
+
-