WordPress.org

Support

Support » Plugins and Hacks » JW Player for Flash & HTML5 Video » JS enqueued on all admin pages

JS enqueued on all admin pages

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author JW Player

    @longtail-video

    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.

    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?

    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.

    Plugin Author JW Player

    @longtail-video

    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?

    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

    Plugin Author JW Player

    @longtail-video

    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?

    How can I revert to version 5?

    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. . .

    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?

    Plugin Author JW Player

    @longtail-video

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

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

    Thanks,

    Jason

    Plugin Author JW Player

    @longtail-video

    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.

    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.

    Plugin Author JW Player

    @longtail-video

    What does the output look like?

    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.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘JS enqueued on all admin pages’ is closed to new replies.
Skip to toolbar