Skip to main content
Login Join
Snippet · PHP

Automatically Rename Uploaded Files to SEO-Friendly Names

Shared by Amit Dholiya · July 30, 2026 · @fallback_intermediate_image_sizes

17 views
Back to Snippets

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

  1. Open your active theme’s functions.php file or a custom functionality plugin.
  2. Add the code below.
  3. Save the file.
  4. 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' );
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments