Document preview
The Document Library Pro plugin lets you allow users to preview files before they download them - or even instead of downloading them. It does this by displaying a preview button or icon in the link
field of the document library, and also on the single document page.
If enabled, the preview option appears next to the link to download/access the document. If you have disabled links to the document then the preview option will appear on its own. When a user clicks on the preview button/icon, the document will option in a popup lightbox.

Document preview options
Document preview
Choose whether or not to enable the preview option. Previews are disabled by default.
You can either configure this option globally on the plugin settings page, or directly in the shortcode as follows:
[doc_library preview="true"]
[doc_library preview="false"]
Preview style
Choose a style for the preview buttons:
- Button with text - A button containing the preview text.
- Button with icon and text - A button containing the preview text and a magnifying glass icon.
- Button with icon (the default) - A button containing a magnifying glass icon only.
- Icon only - A magnifying glass only, not within a button.
- Text link - A text link only.
You can either configure the preview style globally on the plugin settings page, or directly in the shortcode as follows:
[doc_library preview_style="button"]
[doc_library preview_style="button_icon_text"]
[doc_library preview_style="button_icon"]
[doc_library preview_style="icon_only"]
[doc_library preview_style="link"]
Preview text
If you have selected a button or text preview style, then you can choose which text is displayed. The default is 'Preview'.
You can either configure the preview style globally on the plugin settings page, or directly in the shortcode.
Example: [doc_library preview_text="Preview Document Online"]
Which file types are supported?
The preview option is only available for the following file types:
- PDF (pdf**)
- Images (jpeg, gif, png, webp, svg)
- Videos (mp4, ogg*)
- Audio (mp3, mp4, mpeg, ogg*, aac*, aacp*, flac*)
- Microsoft Word (doc, docx***)
- Microsoft Excel (xls, xlsx***)
- Microsoft PowerPoint (ppt, pptx***)
For unsupported file types, no preview option will appear in the list of documents.
* These may require a browser plugin in certain browsers.
** Android OS does not allow previews and requires that the PDF be downloaded.
*** Powered by the Microsoft Office365 Online Viewer, see below for details.
Word, Excel and PowerPoint previews
The previews of Word, Excel and PowerPoint files are powered by the MS Office365 Online Viewer. Your users won't know this because it looks identical to the built-in viewer that Document Library Pro uses for other file types, however you should be aware of this because there are some limitations:
- Privacy - In order for the preview to work, the document will be temporarily uploaded to Microsoft's servers for viewing. If you have GDPR concerns with this then we recommend mentioning it in your privacy and cookies policy and implementing measures such as cookie notices in order to get user from your visitors. Alternatively, if you do not wish to use the MS Office365 Online Viewer then we have provided a developer hook so that you can disable the previews for Word, Excel and PowerPoint files.
- File protection - If you have added file protection to the documents - either with other plugins or custom Apache/NGINX rules - then this is likely to block the MS Office365 Online Viewer for the reasons mentioned above.
- Maximum file size - The MSOffice365 Online Viewer has a maximum file size of 25MB for Excel, 100MB for Word and 300MB for PowerPoint. Document Library Pro will hide the preview icon for files that exceed these limits, so the preview will never appear broken for your users.
Previews for externally hosted files
You can use the document preview for files which are either hosted in the WordPress Media Library or externally using the File URL option.
Files stored on Dropbox should use one of the following URL formats:
- https://dropbox.com/<rest_of_url> or www.dropbox.com/<rest_of_url> - These are site links to dropbox which open the file in the dropbox web app.
- https://dl.dropbox.com/<rest_of_url> or dl.dropboxusercontent.com/<rest_of_url> - These are direct links to the file.
Other ways to preview documents
As well as the preview buttons described above, there are several other ways that you can allow users to preview documents on the page instead of downloading them.
Each document has an individual page, which users can access by clicking on a link to the document (e.g. on the document title). If you set the link destination option to 'Open single document page' then users can be forced to access the single document page before downloading the document.
The single document page is an excellent place to add an on-page preview of the document. The best way to do this depends on the file type, so here are some suggestions for different file types:
- PDF's and other document types - you can upload the file to Google Drive and embed it using a plugin like EmbedPress. Alternatively, you can use a tool like Flipsnack to embed the document as an interactive page turning flip book.
- Google Docs - follow the embedding instructions from Google.
- Audio and video - you can embed audio and video players directly into the single document page.
- Images - use the 'Add Media' button to insert the image into the single document page.
All of these document previews will appear in the main content area of the single document page. The document download link will appear on the right hand side of the page, so users can preview the document before downloading it.