Description
When you upload a PDF, WordPress automatically generates a preview image (thumbnail). If your website doesn’t use PDF previews, disabling this feature can reduce server processing time and save storage space.
Steps
- Open your active theme’s
functions.phpfile or a custom functionality plugin. - Add the code below.
- Save the file.
- Upload a new PDF file. WordPress will no longer generate a preview image.
/**
* Disable PDF preview image generation.
*/
function wpfolks_disable_pdf_previews() {
$fallback_sizes = array();
return $fallback_sizes;
}
add_filter( 'fallback_intermediate_image_sizes', 'wpfolks_disable_pdf_previews' );