hello,
i am using this component for a while, today i recognised that embedded previews are not shown on pages anymore.
hello,
i am using this component for a while, today i recognised that embedded previews are not shown on pages anymore.
How do we get Safari on Mac to allow the use of this plugin? It works fine for me on other browsers, but when I try on Safari it blocks it and even after Iâve turned off content blockers in the preferences/websites section. is there another area where you have to turn blockers off somewhere? Any help appreciated.
I really donât know so this is just waste of bandwidth but Safari has been problematic before because of its quite hard CSP rules and other security matters. But it should then break all Safari versions, not only Macâs,I reckon.
It works for me in Mac Safari. The only place where it does not work for me is on an iPhone (Safari, FF, and Chrome). I havenât tested on iPad recently.
All web browsers on iOS/iPadOS use the exact same rendering engine (WebKit) due to Appleâs restrictions, so that wouldnât really matter anyway.
Try updating Safari to the latest version.
I just pushed a new update.
You can now disable the preview for specific PDF files. It doesnât work exactly like oneboxes because that would be a bit complicated to implement in a theme component, but itâs very similar.
When you upload a PDF, youâll see this in the composer by default.
[file.pdf|attachment](upload://2cLML0SIwebGHDjlKRVzZ3VRv0f.pdf) (524.1 KB)
All you need to do is add a space before the file name like so
[ file.pdf|attachment](upload://2cLML0SIwebGHDjlKRVzZ3VRv0f.pdf) (524.1 KB)
Note that the space needs to be inside the brackets. It wonât have any impact on the file name when you download it, and it will also not have any impact on the file description rendered in the post.
Once you do that, the PDF will not have a preview attached to it in the cooked post.
The update adds a new setting.
It has two options.
Inline
and New Tab
If you select Inline
PDF previews will be rendered in the post like before.
If you select New Tab
the component wonât create an inline preview. However, the link for the attachment will open a new tab. The new tab will display the PDF file in the native browser reader.
and the icon next to the attachment link will change to external-link
instead of download
The default for the setting is Inline
So⌠it wonât affect sites that had this component installed before the update. It only adds a new option that you need to toggle.
There have been some reports about this not working on Safari and some iOS devices - which I havenât been able to reproduce. The update tries to address that by loading the PDF as a base64 URL instead of a blob - which I read is very finicky on Apple devices.
Please update the component - and make sure your browser is updated as well. If, for some reason, it doesnât work for you on an Apple device, please check the browser console - if possible - and let me know what you see.
Since updating to latest, 2.8.0.beta6 (a1daf9fe53), PDF previews seem like they are loading slightly slower, and in at least one case, one PDF out of three in the post doesnât show up in Chrome:
Itâs not a caching issue - even after clearing Chromeâs cache, saving the PDF with a slight change and re-uploading, the preview still wonât show up. There are no entries in the error log. Chrome is updated to latest.
Console:
Iâm on 2.8.0.beta6. PC - Windows 10. Similar observation. Firefox is a bit slow, but the preview eventually loads. Chrome wonât show it, it seems to freeze on this gray placeholder.
Thanks for the details. Since two of those loaded fine, I figured that it probably has something to do with the file size⌠and it turns out that is indeed the case.
If I upload a large PDF, it works fine in Firefox but chokes on Chrome. I read a little bit about this, and it seems like the length limit that a base64 URL is largely decided by the vendor. Firefox has no limits. Chrome caps them at 2mb.
So, this means that a base64 URL is not a viable option, and weâd have to go back to blob URLs. It seems safari has better support if the preview element is an <object>
tag instead of an iFrame.
So, this PR changes everything back to a blob URL and changes the tag to <object>
This will definitely resolve the issue for large files on Chrome and hopefully fix the issues on Apple devices.
https://github.com/discourse/discourse-pdf-previews/pull/3/files
Please update the component again and let me know if you still have any issues.
The file sizes in the post with 3 PDFs are 548.3 KB, 1.1 MB, and 1.6 MB, in that order from the top. After updating the component alone, the previews do show up, but no longer at full width in Chrome:
EDIT: FF looks the same as Chrome above and Safari is not showing previews, but gray boxes:
Thanks, I pushed a small fix for the size issue.
It probably wonât fix the issue on Safari, but please try and let me know.
Yes - Chrome and FF are fixed, Safari remains the same with just the gray boxes.
Just to confirm, Safari used to work for you before, right?
Yes, up until the recent update all desktop browsers were working fine. I canât say how far back Safari was OK because itâs not my daily browser, but I can say that it has worked sometime in the past.
This commit should fix Safari.
I just tested it on a MacBook, and it works fine for me in Safari, Chrome, and Firefox.
If anyone sees this issue
Itâs an issue in your setup, not in the component.
How to unblock a blocked plug-in to displ⌠- Apple Community
Also, please note that this component never supported PDF previews on mobile phones - as defined by Discourse, whether it be iOS or Android. So, thatâs the expected behavior.