videopress_override_media_templates

Our video overrides!.

Description

videopress_override_media_templates(); 

We have a template for the iframe to get injected.


Usage

  1. if ( !function_exists( 'videopress_override_media_templates' ) ) { 
  2. require_once '/modules/videopress/editor-media-view.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = videopress_override_media_templates(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/modules/videopress/editor-media-view.php  
  1. function videopress_override_media_templates() { 
  2. ?> 
  3. <script type="text/html" id="tmpl-videopress_iframe_vnext"> 
  4. <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> 
  5. </script> 
  6. <script> 
  7. (function( media ) { 
  8. // This handles the media library modal attachment details display. 
  9. if ( 'undefined' !== typeof media.view.Attachment.Details.TwoColumn ) { 
  10. var TwoColumn = media.view.Attachment.Details.TwoColumn,  
  11. old_render = TwoColumn.prototype.render,  
  12. vp_template = wp.template('videopress_iframe_vnext'); 
  13.  
  14. TwoColumn.prototype.render = function() { 
  15. // Have the original renderer run first. 
  16. old_render.apply( this, arguments ); 
  17.  
  18. // Now our stuff! 
  19. if ( 'video' === this.model.get('type') ) { 
  20. if ( this.model.get('videopress_guid') ) { 
  21. this.$('.attachment-media-view .thumbnail-video').html( vp_template( { 
  22. guid : this.model.get('videopress_guid'),  
  23. width : this.model.get('width'),  
  24. height : this.model.get('height') 
  25. })); 
  26. }; 
  27. } else { /* console.log( 'media.view.Attachment.Details.TwoColumn undefined' ); */ } 
  28.  
  29. // This handles the recreating of the core video shortcode when editing the mce embed. 
  30. if ( 'undefined' !== typeof media.video ) { 
  31. media.video.defaults.videopress_guid = ''; 
  32.  
  33. // For some reason, even though we're not currently changing anything, the following proxy 
  34. // function is necessary to include the above default `videopress_guid` param. \_(*)_/ 
  35. var old_video_shortcode = media.video.shortcode; 
  36. media.video.shortcode = function( model ) { 
  37. // model.videopress_guid = 'FOOBAR'; 
  38. return old_video_shortcode( model ); 
  39. }; 
  40. } else { /* console.log( 'media.video undefined' ); */ } 
  41.  
  42. })( wp.media ); 
  43. </script> 
  44. <?php