WordPress.org

Forums

Easy FancyBox
disable Easy FancyBox on mobile devices? (9 posts)

  1. kchayka
    Member
    Posted 3 years ago #

    I'm using EFB (which I really like) for photo galleries in themes intended for desktops/laptops, but also using a theme switcher plugin for mobile devices. The lightbox is really really tiny on small screens so I'd like to disable EFB just in the mobile theme.

    I've figured out how to dequeue selected scripts and styles in the mobile theme, but it doesn't completely disable all the EFB code and I end up with JavaScript errors. :-(

    Is it possible to do what I want?

    http://wordpress.org/extend/plugins/easy-fancybox/

  2. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    Hi,

    I see what you mean... Currently there is no easy way but I'll think about adding one for a future release.

    At this point you'll have to jump some more hoops:

    1. Make sure the main jQuery library is loaded in the mobile theme (you can leave the FancyBox scripts out but you might have to (re)enqueue jquery)
    2. Add this to the theme footer via an add_action 'wp_footer' call (see http://codex.wordpress.org/Plugin_API/Action_Reference/wp_footer) in functions.php :
    <script type="text/javascript">
    jQuery(document).unbind('ready');
    </script>

    This last step will 'unbind' FancyBox from all images but it will also unbind all other fucntions that are supposed to be loaded at document.ready ... but there will probably be no others in your case.

    Hope this helps :)

  3. kchayka
    Member
    Posted 3 years ago #

    Thanks for the speedy response. I'll give it a try.

  4. kchayka
    Member
    Posted 3 years ago #

    No go. :(

    I can see the unbind JS in the page source just before </body>, but EFB doesn't disable unless I also dequeue and/or deregister 'jquery.fancybox', which gives a JS error due to the embedded EFB JS code in the head:
    Error: TypeError: $("a.fancybox, area.fancybox").fancybox is not a function

    This error causes problems with another script, whether or not I re-enqueue jquery.

    If I could conditionally disable that embedded code that would do it. I tried adding
    remove_action('wp_head', 'easy_fancybox', 9999);
    to the mobile theme but it doesn't remove it. I also tried checking for the mobile theme (Weaver II) in the easy_fancybox function but WP only sends the default theme name (Twenty Eleven). :(

    Bummer. I'd really like to figure something out. This is such a nice script for larger displays but not so good on small screens.

  5. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    Strange, I tested the code on my own site in a text widget and there it works just fine...

    If you want to use remove_action('wp_head', 'easy_fancybox', 9999); you should be able to get it working if you make sure this remove action is triggered AFTER all plugins are loaded and BEFORE the wp_head() function blurts out the fancybox routine. You'll have to make a detour something like this:

    function fancybox_removal() {
      remove_action('wp_head', 'easy_fancybox');
    }
    add_action('plugins_loaded','fancybox_removal');

    Maybe even add_action('wp_head','fancybox_removal', 0); would work...

  6. kchayka
    Member
    Posted 3 years ago #

    None of the above are working for me. Maybe there is something about WP 3.4 that is interfering?

  7. RavanH
    Member
    Plugin Author

    Posted 3 years ago #

    got a link to your site?

  8. kchayka
    Member
    Posted 3 years ago #

    localhost only at this time. It's in testing before I dare go "live" but I'll see if I can get a beta site up somewhere.

    thanks again for your effort

  9. kchayka
    Member
    Posted 3 years ago #

    I think I'm going to go with a different mobile theme switcher that let me selectively disable other plugins.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic