acf/upload/generate_previews

Last updated Nov 2, 2026

Overview

Control whether files uploaded through the basic uploader get preview images.

Description

When a File or Image field uses the basic uploader, such as in a front-end form, ACF asks WordPress to generate the attachment’s metadata. For users without the upload_files capability, ACF tells WordPress not to render PDF preview images or save cover art embedded in audio and video files. This includes logged-out visitors, Subscribers, and Contributors. Images uploaded this way still get their normal thumbnail sizes.

Use this filter to turn previews back on if you trust the people uploading through your forms, or to turn them off for everyone.

Parameters

apply_filters( 'acf/upload/generate_previews', $generate_previews, $file, $id );

$generate_previews (bool) Whether to generate preview images. Default: true for users with the upload_files capability, otherwise false

$file (string) The path to the uploaded file.

$id (int) The attachment ID.

Example

Generate previews for logged-in users

add_filter( 'acf/upload/generate_previews', function () {
    return is_user_logged_in();
} );

Generate previews for everyone

add_filter( 'acf/upload/generate_previews', '__return_true' );

Changelog

  • Added in version 6.8.11

Notes

  • Generating PDF previews sends the uploaded file to the server’s image libraries, such as Imagick and Ghostscript. Only turn previews on for uploaders you trust.
  • Uploads through the Media Library aren’t affected by this filter.
  • Without previews, PDFs show a generic document icon in the Media Library.
Supercharge Your Website With Premium Features Using ACF PRO

Speed up your workflow and unlock features to better develop websites using ACF Blocks and Options Pages, with the Flexible Content, Repeater, Clone, Gallery Fields & More.

Explore Features View Pricing

PRO Features
ACF Blocks
Options Pages
PRO Fields
Repeater
Flexible Content
Gallery
Clone

Related