Drush command to generate thumbnails

Created on 2 September 2025, 12 days ago

Problem/Motivation

When doing a migration of thousands of media items, going to the Media overview page takes a very long time to load (presumably its generating thumbnails). It would be great to have a Drush command to let this happen in the background.

Proposed resolution

Add the Drush command to generate thumbnails ahead of time and in the background.

Feature request
Status

Active

Version

7.0

Component

Code

Created by

🇺🇸United States kevinquillen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @kevinquillen
  • 🇫🇷France sgostanyan

    I understand the concern: when migrating thousands of media items, the Media overview page can become very slow if it has to generate many thumbnails on the fly.

    It’s important to note how Media PDF Thumbnail works:

    Thumbnail generation is intentionally tied to the field formatter configuration (image format JPG/PNG, which PDF page to render, etc.).
    These parameters are not global to the media item, but depend on the display context (entity view mode, Views field formatter, etc.).
    That’s why the module is designed for “lazy generation at display time”: the thumbnail is created only when needed, based on the formatter’s settings.

    To avoid blocking page loads, the module already provides an option to push thumbnail generation into a queue processed by cron.

    On first display, instead of generating synchronously, the module enqueues the job (/admin/media-pdf-thumbnail/settings/queue). This way, thumbnails are generated asynchronously, respecting the actual formatter configuration.

    A Drush command that blindly generates all thumbnails ahead of time would not fully solve the problem, because it cannot know which page/format to generate without context. It would risk generating the wrong thumbnails or duplicates. The queue/cron approach is more reliable, as it’s directly tied to the formatter usage.

    You can refer to the guide for further details : https://www.drupal.org/docs/extending-drupal/contributed-modules/contrib...

Production build 0.71.5 2024