Inline PDF Previews

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.

10 Likes