WordPress.org

Forums

JW Player for Flash & HTML5 Video
JS enqueued on all admin pages (17 posts)

  1. Jason Bahl
    Member
    Posted 2 years ago #

    It appears that the JS is being enqueued on ALL admin pages which is causing conflicts with other plugins, such as Revolution Slider.

    http://wordpress.org/extend/plugins/jw-player-plugin-for-wordpress/

  2. JW Player
    Member
    Plugin Author

    Posted 2 years ago #

    Can you elaborate on what is conflicting? Do you have an example?

    The "Revolution Slider" plugin is not freely available. It says it's about responsiveness, which could indicate it is using fitVids.js. Fitvids is not compatible with JW player 6.

  3. Jason Bahl
    Member
    Posted 2 years ago #

    Thanks for the quick response!

    I get the following JS error on admin pages:

    Uncaught Error: Syntax error, unrecognized expression: [jwplayer mediaid="699"]

    It appears that this is caused by the js files being enqueued on ALL admin pages, rather than just the admin pages that actually need the js.

    I added a function to my codebase that dequeues the JWPlayer scripts for all non JW Player Admin Pages, which is something your plugin probably shouldn't be doing in the first place, but the error still occurs after clicking the "Insert into Post" button from the media library within the media uploader thickbox.

    Because the error comes up after a button click, I'm thinking it might have something to do with how AJAX is being processed?

  4. Jason Bahl
    Member
    Posted 2 years ago #

    It looks like it's an issue with the function media_send_to_editor in jwp6-class-media.php

    This function is filtering the send_to_editor function, and it's having the shortcode be sent rather than the image I'm trying to insert.

    I believe there needs to be some sort of condition to make sure the shortcode isn't being sent rather than the image that's supposed to be sent.

  5. JW Player
    Member
    Plugin Author

    Posted 2 years ago #

    The generic JW Player script is embedded in each Admin Page. This is basically done for simplicity reasons.

    However the error you are describing sounds strange. The expression [jwplayer mediaid="699"] is a JW shortcode specific for your website and is not used in our javascript. You get this error on all pages?

  6. Jason Bahl
    Member
    Posted 2 years ago #

    I started noticing the error on the revolution slider page.

    I haven't investigated too much further yet. I know that if I remove the filter:

    add_filter('media_send_to_editor', array('JWP6_Media', 'media_send_to_editor'), 11, 3);

    from the JW Player plugin, that all works with the revolution slider, but I know that causes some functionality to break in the JW Player plugin.

    Here's a screenshot of the button that causes the error: http://cl.ly/image/202f3E1W0q3r

  7. JW Player
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks for the additional information. I will look into it.

    Can you check if you get the same error when you revert to the JW Player 5 version of the plugin?

  8. Jason Bahl
    Member
    Posted 2 years ago #

    How can I revert to version 5?

  9. Jason Bahl
    Member
    Posted 2 years ago #

    I changed line 260 of jwp6-class-media.php from:

    if ( isset($shortcode) ) return $shortcode->shortcode();

    to

    if ( isset($shortcode) ) $html = $html . $shortcode->shortcode();

    This appears to work with the revolution slider now and as far as I can tell, this doesn't screw up the JWPlayer plugin either. . .

  10. Jason Bahl
    Member
    Posted 2 years ago #

    A little info on why I made that change:

    The Revolution Slider has some javascript that gets the Image that's being sent to the editor, extracts the URL, then it uses that image to generate a new slide.

    I changed the function in the revolution slider from:

    window.send_to_editor = function(html) {
    
    			 tb_remove();
    			 var urlImage = jQuery(html).attr('src');
    			 if(!urlImage || urlImage == undefined || urlImage == "")
    				var urlImage = jQuery('img',html).attr('src');
    
    			onInsert(urlImage);
    		}

    to

    window.send_to_editor = function(html) {
    
    alert(html);
    		}

    to see what was getting passed through.

    The JWPlayer shortcode was getting passed through instead of the image. This led me to find the filter in the JWPlayer plugin that is filtering the media_send_to_editor function.

    My solution now sends both the intended image AND the shortcode, so the url abstraction that the Revolution Slider is using still works.

    I still think there's a better solution that will leave that filter alone if the Insert to Post button is not clicked specifically for the JWPlayer plugin, as sending the image AND the shortcode likely isn't a solid resolution to the issue and will likely cause conflicts with other plugins.

    Perhaps an alternative to using that filter would be to use JS to send the data needed to the editor?

  11. JW Player
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks for the elaborate research. I will look into it a.s.a.p.

  12. Jason Bahl
    Member
    Posted 2 years ago #

    Thanks for your quick response and attention to the plugin. Let me know when you implement a fix.

    Thanks,

    Jason

  13. JW Player
    Member
    Plugin Author

    Posted 2 years ago #

    I hope we can find it. Extending the new media manager is not very well documented and a lot of it is trial and error.

  14. rquantz
    Member
    Posted 1 year ago #

    I'm glad someone else is having this problem. It took me a while to narrow it down to the media_send_to_editor filter.

    The issue I'm having is using Jared Atchison's excellent Custom Metaboxes and Fields for WordPress library (it's not a plugin, you include it in a plugin or theme). When using a "file" formatted metafield that calls the media uploader, if I try to insert a video, I believe it attempts to insert the shortcode instead of the file url.

    Any help or suggestions for removing the JW filter just from certain field uploads would be great. I'll be working to figure out a way around it too.

  15. JW Player
    Member
    Plugin Author

    Posted 1 year ago #

    What does the output look like?

  16. CharlyLeetham
    Member
    Posted 1 year ago #

    Hi, Thanks Jason Bahl for your well documented fix.

    We're using WooThemes Canvas with custom upload metaboxes and noted the upload box would return a blank screen, although it would input the file into the correct field.

    We we clicked the 'use as image' button, we received the following error:
    Uncaught Error: Syntax error, unrecognized expression: [jwplayer mediaid=397] (the media id would change based on the file uploaded.

    We implemented the fix suggested by Jason and the problem was resolved.
    Currently using JW Player Version 2.1.1 on WP 3.8

    It would be great to have the fix permanently included so we don't have to patch each time we update.

  17. JW Player
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks, we can look into fixing that.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • JW Player for Flash & HTML5 Video
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic