Support » Plugin: Easy FancyBox » disable Easy FancyBox on mobile devices?

  • 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?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author RavanH



    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 in functions.php :
    <script type=”text/javascript”>

    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 🙂

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

    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.

    Plugin Author RavanH


    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');

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

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

    Plugin Author RavanH


    got a link to your site?

    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

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

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘disable Easy FancyBox on mobile devices?’ is closed to new replies.