[wp-trac] [WordPress Trac] #45377: Video Shortcode Ajax Issue

WordPress Trac noreply at wordpress.org
Mon Nov 19 13:34:23 UTC 2018


#45377: Video Shortcode Ajax Issue
-----------------------------+-----------------------------
 Reporter:  Nenad Obradovic  |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Shortcodes       |    Version:  5.0
 Severity:  minor            |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 Hi guys,

 I have the problem with wp_video_shortcode element settings on ajax
 trigger, where defaults_atts variable override settings I forward to
 shortcode. Because is_admin() conditional inside shortcode function return
 true on ajax calling.

 Example code

 {{{
 <div class="video-player-element">
         <?php
         // Get video meta src
         $video_meta = get_post_meta( get_the_ID(), 'video_player_src',
 true );

         // Video player settings
         $settings = apply_filters( 'video_player_settings', array(
                 'width'  => 1300, // Aspect ration is 16:9
                 'height' => 731,
                 'loop'   => true
         ) );

         // Init video player
         echo wp_video_shortcode( array_merge( array( 'src' => esc_url(
 $video_meta ) ), $settings ) ); ?>
 </div>
 }}}

 When I call ajax to load the new content on frontend, video player element
 is loaded with my settings but on rendering video, wp_video_shortcode
 function override my settings with default because function enters inside
 this conditional


 {{{
 if ( is_admin() ) {
         // shrink the video so it isn't huge in the admin
         if ( $atts['width'] > $defaults_atts['width'] ) {
                 $atts['height'] = round( ( $atts['height'] *
 $defaults_atts['width'] ) / $atts['width'] );
                 $atts['width'] = $defaults_atts['width'];
         }
 }
 }}}

 Is there any solutions to skip this check, or if you add some filter
 around defaults_atts so I can be able to change that values? Thanks for
 your solutions

 Best regards,
 Nenad

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45377>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list