This project is not covered by Drupal’s security advisory policy.

Generates a ThumbHash for every image file and stores it with the file. A ThumbHash is a placeholder of about 30 characters that clients decode into a blurred preview while the image loads.

Features

  • Adds a thumbhash field to file entities.
  • Generates the hash when an image file is saved for the first time or replaced.
  • Downscales with an image style first, so it works with GD and ImageMagick. SVG is skipped.
  • Can generate the hashes during cron instead of on save.
  • Drush command for existing files.

Post-Installation

No configuration is needed. Run drush thumbhash:generate once for existing images (options: --limit, --force, --queue).

Settings are at /admin/config/media/thumbhash: the image style used for downscaling, and whether to generate the hashes during cron.

The module does not display the hashes. Read them with:

  • PHP: $file->get('thumbhash')->value
  • JSON:API: the thumbhash attribute of file resources
  • Core REST: thumbhash[0].value, once the entity:file resource is enabled

The hash describes the original image, so it won't match image styles that crop.

Additional Requirements

Similar projects

  • Blurhash: calculates a BlurHash on every render and doesn't store it.
  • Image Blurry Placeholder: adds a tiny background image in the core image formatters. It provides no hash for APIs.

Project information

  • Project categories: Media
  • Created by coffeemakr on , updated
  • shield alertThis project is not covered by the security advisory policy.
    Use at your own risk! It may have publicly disclosed vulnerabilities.

Releases