• Resolved alabasterized

    (@alabasterized)


    Hello,

    The autodetect option appears very useful, and for me it is more convenient than adding the class to each file. However, it is redundant for the externally hosted files (and it is normal to have the external links to PDF files).

    So, is it possible to have the autodetect option enabled, yet to exclude externally hosted files from it?

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi, no all media links are treated the same. But what you could do it add some custom javascript that will set “nofancybox” to all external links.

    Try this in an HTML widget in the footer:

    
    <script>
    document.querySelectorAll("a").forEach( (el) => {
        new URL(el.href).host !== (location.host) && el.classList.add("nofancybox");
    });
    </script>
    
    Thread Starter alabasterized

    (@alabasterized)

    Thanks for your help, however this did not work for me. I tried it in the header too.

    BTW, external PDFs do open in another tab. But fancybox pops up too, and it remains empty. But I’d like it disabled in this case anyhow.

    The script should go in the footer, after all the links in the content. If you can share a link to your site, I can verify why it’s working.

    Thread Starter alabasterized

    (@alabasterized)

    Yes, I tried adding this code to the footer, in different places, but it did not work.

    I will check this more closely, but since I don’t have a lot of such external links, I tried adding manually class=”nofancybox” to them, and for now it looks like it works.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Autodetect and external links’ is closed to new replies.