Title: have pdf popups confined to pdf links only on own domain
Last modified: March 7, 2018

---

# have pdf popups confined to pdf links only on own domain

 *  Resolved [Starhorsepax2](https://wordpress.org/support/users/starhorsepax2/)
 * (@starhorsepax2)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/fallback-for-external-pdfs-without-https/)
 * 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.
    -  This topic was modified 8 years, 1 month ago by [Starhorsepax2](https://wordpress.org/support/users/starhorsepax2/).
    -  This topic was modified 8 years, 1 month ago by [Starhorsepax2](https://wordpress.org/support/users/starhorsepax2/).
    -  This topic was modified 8 years, 1 month ago by [Starhorsepax2](https://wordpress.org/support/users/starhorsepax2/).

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

 *  [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/fallback-for-external-pdfs-without-https/#post-10060579)
 * > 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](https://wordpress.org/support/users/starhorsepax2/)
 * (@starhorsepax2)
 * [8 years ago](https://wordpress.org/support/topic/fallback-for-external-pdfs-without-https/#post-10078784)
 * 🙂 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.

 * ![](https://ps.w.org/easy-fancybox/assets/icon-256x256.png?rev=3188201)
 * [Firelight Lightbox](https://wordpress.org/plugins/easy-fancybox/)
 * [Support Threads](https://wordpress.org/support/plugin/easy-fancybox/)
 * [Active Topics](https://wordpress.org/support/plugin/easy-fancybox/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/easy-fancybox/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/easy-fancybox/reviews/)

## Tags

 * [HTTP](https://wordpress.org/support/topic-tag/http/)
 * [HTTPS](https://wordpress.org/support/topic-tag/https/)
 * [mixed content warning](https://wordpress.org/support/topic-tag/mixed-content-warning/)
 * [pdf](https://wordpress.org/support/topic-tag/pdf/)

 * 2 replies
 * 2 participants
 * Last reply from: [Starhorsepax2](https://wordpress.org/support/users/starhorsepax2/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/fallback-for-external-pdfs-without-https/#post-10078784)
 * Status: resolved