PDF on iPad and iPhone
Your Account / Forums / Easy FancyBox Pro / PDF on iPad and iPhone
Tagged: Google Viewer, PDF
- This topic has 7 replies, 3 voices, and was last updated 11 years, 6 months ago by
RavanH.
-
AuthorPosts
-
-
April 9, 2015 at 7:06 am #4782
When I try to open a pdf in fancybox on iPad or iPhone it just opens a blank box, the pdf does not load. Is there a setting that will make it responsive and available on mobile devices.
-
To view a PDF file in a browser, you need a PDF reader browser plugin. iDevices are known to not have that preinstalled nor is such a plugin available. The only solution is to use an external PDF viewer solution.
Something like the alternative method #2 on http://demo.status301.net/easy-fancybox-sandbox/pdf-embeds but I cannot tell you for how long Google will continue to allow displaying of files outside those hosted on Google Drive… Underneath the link, you’ll see example code of how this works in Easy FancyBox.
-
April 9, 2015 at 9:56 pm #4791
I also saw an older post that had some code you could put in the footer that would disable the plugin for mobile devices. I tried it and it disabled the plugin for all devices including desktops, but again, it was an older post. Do you have new code like that I could use in the footer that works?
-
This code in a text widget should do the trick:
<script type="text/javascript"> var pixelRatio = window.devicePixelRatio || 1; //alert('Screen size: ' + window.innerWidth + ' / ' + pixelRatio + ' = ' + window.innerWidth/pixelRatio); if( window.innerWidth/pixelRatio < 420 ) { //alert('Fancybox disabled.'); easy_fancybox_handler = null; }; </script>For testing purposes, remove the
//in front of thealert(...)lines. It will create a message stating calculated screen width and a message if FancyBox is disabled on smaller devices. Remove those alert lines after testing.EDIT: Oh, and change the value
420to disable FancyBox starting from another screen size. -
April 10, 2015 at 1:28 pm #4793
Thanks. Will this work in the footer too? I have a large site and don’t want to put a text widget on every page.
-
Yes, in the themes footer.php is fine, as long as you place the snippet BEFORE/ABOVE the
<?php wp_footer(); ?>call. When placed after it, the snippet will have no effect.But please be aware that theme updates will overwrite your changes, unless you’re using a custom theme. If you’re not using a custom theme, then you might want to create a child theme to prevent footer.php from being overwritten in the future.
-
April 21, 2015 at 2:51 pm #4846
Thanks, this is working great, except it turns of the fancy box for all files, not just pdf. Is there a way to make this script work for pdf files only? I still want my videos to work on iPad. Thanks.
-
-
AuthorPosts
- You must be logged in to reply to this topic.
