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
thumbhashfield 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
thumbhashattribute of file resources - Core REST:
thumbhash[0].value, once theentity:fileresource is enabled
The hash describes the original image, so it won't match image styles that crop.
Additional Requirements
- Drupal 11.2 or later
- srwiez/thumbhash, which Composer installs for you
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
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.