Disable PDF Preview in WordPress Media Gallery
If you’ve ever uploaded a PDF to your WordPress site and noticed that WordPress automatically generates a preview image, you’re not alone. Since WordPress 4.7, this feature has been enabled by default.
While it’s helpful for some, others may find it unnecessary or even problematic—especially if you’re managing a large media library or want to conserve server resources.
In this post, we’ll walk you through why you might want to disable PDF previews and how to disable the previews safely and effectively.
Why Disable PDF Previews?
Here are a few reasons you might want to turn off this feature:
- Performance: Generating preview images can slow down uploads, especially for large PDFs.
- Storage: Each preview image takes up additional space on your server.
- Aesthetics: You may prefer a cleaner Media Library without auto-generated thumbnails.
- Control: You might want to use your own custom icons or thumbnails instead.
Disabling PDF previews in WordPress is a simple tweak that can streamline your media management and improve performance. Whether you’re a developer or a casual site owner, taking control of how your media behaves is always a win.
How WordPress Generates PDF Previews
WordPress uses the Imagick PHP extension to create a JPEG preview of the first page of your PDF. This image is then treated like any other media attachment and appears in your Media Library.
How to Disable PDF Previews
There are two main ways to disable this feature: via a plugin or by adding custom code to your theme.
Option 1: Add a Code Snippet to Your Theme
You can disable PDF previews by adding the following code to your theme’s functions.php file or a custom plugin:
add_filter( ‘fallback_intermediate_image_sizes’, ‘disable_pdf_previews’ );
function disable_pdf_previews( $fallbacksizes ) { return []; }
This filter tells WordPress not to generate any fallback image sizes for PDFs, effectively disabling the preview.
Important: Always back up your site before editing theme files, and consider using a child theme to avoid losing changes during updates.
Option 2: Use an Existing WordPress Plugin
If you’re not comfortable editing code, you can use a plugin like Code Snippets to safely add the code above without touching your theme files.
- Install and activate the Code Snippets plugin.
- Go to Snippets > Add New.
- Paste the code snippet above.
- Save and activate the snippet.
Verifying It Works
After applying the change:
- Upload a new PDF via Media > Add New.
- Check the Media Library—there should be no preview image generated.
- Only the original PDF file should appear.
Optional: Clean Up Existing PDF Previews
Disabling previews won’t remove existing ones. To clean up old preview images:
- Use a plugin like Media Cleaner or WP-Optimize to remove unused media files.
- Manually delete preview images via FTP or your hosting file manager (look for files with the same name as your PDF but with
.jpgextensions).
Conclusion
I welcome your thoughts, questions or suggestions on my article on how to disable PDF previews within the Media Gallery on WordPress.
You may support my work by sending me a tip using your Brave browser or by sending me a one time donation using your credit card.
Let me know if you found any errors within my article or if I may further assist you by answering any additional questions you may have.




