summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/videopress/editor-media-view.php')
-rw-r--r--plugins/jetpack/modules/videopress/editor-media-view.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/plugins/jetpack/modules/videopress/editor-media-view.php b/plugins/jetpack/modules/videopress/editor-media-view.php
index f9ff3498..9fffaafa 100644
--- a/plugins/jetpack/modules/videopress/editor-media-view.php
+++ b/plugins/jetpack/modules/videopress/editor-media-view.php
@@ -73,7 +73,7 @@ function videopress_editor_view_js_templates() {
<script type="text/html" id="tmpl-videopress_iframe_vnext">
<div class="tmpl-videopress_iframe_next" style="max-height:{{ data.height }}px;">
<div class="videopress-editor-wrapper" style="padding-top:{{ data.ratio }}%;">
- <iframe style="display: block;" width="{{ data.width }}" height="{{ data.height }}" src="https://videopress.com/embed/{{ data.guid }}?{{ data.urlargs }}" frameborder='0' allowfullscreen></iframe>
+ <iframe style="display: block; max-width: 100%; max-height: 100%;" width="{{ data.width }}" height="{{ data.height }}" src="https://videopress.com/embed/{{ data.guid }}?{{ data.urlargs }}" frameborder='0' allowfullscreen></iframe>
</div>
</div>
</script>
@@ -170,7 +170,7 @@ function add_videopress_media_overrides() {
function videopress_override_media_templates() {
?>
<script type="text/html" id="tmpl-videopress_iframe_vnext">
- <iframe style="display: block; max-width: 100%;" width="{{ data.width }}" height="{{ data.height }}" src="https://videopress.com/embed/{{ data.guid }}?{{ data.urlargs }}" frameborder='0' allowfullscreen></iframe>
+ <iframe class="videopress-iframe" style="display: block; max-width: 100%; max-height: 100%;" width="{{ data.width }}" height="{{ data.height }}" src="https://videopress.com/embed/{{ data.guid }}?{{ data.urlargs }}" frameborder='0' allowfullscreen></iframe>
</script>
<script>
(function( media ){
@@ -189,8 +189,8 @@ function videopress_override_media_templates() {
if ( this.model.get('videopress_guid') ) {
this.$('.attachment-media-view .thumbnail-video').html( vp_template( {
guid : this.model.get('videopress_guid'),
- width : this.model.get('width'),
- height : this.model.get('height')
+ width : this.model.get('width') > 0 ? this.model.get('width') : '100%',
+ height : this.model.get('height') > 0 ? this.model.get('height') : '100%'
}));
}
}
@@ -210,6 +210,16 @@ function videopress_override_media_templates() {
};
} else { /* console.log( 'media.video undefined' ); */ }
+ // override the media modal in order to extend the escape method to unload the player on hide
+ var BaseMediaModal = wp.media.view.Modal;
+
+ wp.media.view.Modal = BaseMediaModal.extend( {
+ escape: function () {
+ BaseMediaModal.prototype.escape.apply( this );
+ var playerIframe = document.getElementsByClassName( "videopress-iframe" )[0];
+ playerIframe.parentElement.removeChild( playerIframe );
+ }
+ } );
})( wp.media );
</script>
<?php