• Resolved Starhorsepax2

    (@starhorsepax2)


    We just recreated a whole site in wordpress and have pdfs set to use the lightbox. We like the lightbox for this.
    But is there any way to have the plugin confine that lightbox to its own domain only? There are times the user is linking straight to pdfs on other sites and they are blocked by the mixed content. (Ours is http, the other is https).
    In fact, even if the ARE https like ours they are opening a new tab as well as opening the lightbox.

Viewing 2 replies - 1 through 2 (of 2 total)
  • But is there any way to have the plugin confine that light box to its own domain only?

    You can switch OFF Auto-detection of PDF media links, and then give each PDF link that you do want to show inside the light box a class=”fancybox-pdf” attribute. But if you want auto-detection but for your own domain only, you will need add some script to either exclude external links or include internal ones.

    Let’s say you leave auto-detection ON. Then the following little script added to your theme’s footer.php (above the wp_footer.php call) or in a sidebar HTML widget might do the trick to automatically exclude external links:

    
    <script type="text/javascript">
    jQuery(function($){
      var domain_name = location.hostname.replace("www.","");
      $('a[href*=".pdf"], a[href*=".PDF"], area[href*=".PDF"]').filter(function() {
        return this.hostname && this.hostname.replace("www.","") !== domain_name;
      }).addClass('nolightbox');
    });
    </script>
    

    Untested so let me know how it works out 🙂

    In fact, even if the ARE https like ours they are opening a new tab as well as opening the lightbox.

    This may be caused by external click tracking on your site…

    Thread Starter Starhorsepax2

    (@starhorsepax2)

    🙂 Thank you! It seems to work!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘have pdf popups confined to pdf links only on own domain’ is closed to new replies.