Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Sodium 3.0.2 Minor update available for module sodium (3.0.2). Release: Snipper 1.0.4 Minor update available for module snipper (1.0.4). Release: X-Frame-Options Allow-From webvisor.com 2.0.2 Minor update available for module xframe_allow_webvisor (2.0.2). Release: Swagger UI Info 2.0.2 Minor update available for module swagger_ui_info (2.0.2). Release: Contact Mail 2.0.4 Minor update available for module contact_mail (2.0.4). Release: Varbase Webform Base 1.0.1 Minor update available for module varbase_webform_base (1.0.1). Release: BootBase 2.0.3 Minor update available for theme bootbase (2.0.3). Release: URL Rewriter 1.0.0-alpha4 New alpha version released for module url_rewriter (1.0.0-alpha4). Usage Milestone: Term CSV Export Import Module term_csv_export_import crossed 1,000 active installs. Module Revived: Year/Month Widget 1.1.3 Module year_month_widget updated after 9 months of inactivity (1.1.3).

Grout Image Placeholder

No security coverage Drupal 10–11
View on drupal.org

This module provides fallback images from the Grout API for empty media fields, useful for bulk content imports. It offers a field formatter to display real images when available or Grout-generated avatars or placeholders when not, ensuring consistent sizing. You can also use Twig filters and functions for direct template integration.

Introduction

Grout Image integrates with the Grout on-demand image API to provide automatic fallback images whenever media fields are empty. It is designed for sites that perform bulk content imports (movies, books, people) where posters, covers, or headshots may not always be available.

The module provides:

  • A URL generator service (grout_image.url_generator) that builds Grout avatar and placeholder URLs from configurable defaults.
  • Twig filter grout_avatar and function grout_placeholder for use directly in templates.
  • A field formatter "Grout Fallback" for entity_reference fields that target media entities: shows the real image when present, and a Grout-generated image when the field is empty. The fallback is sized to match the output dimensions of the selected Drupal image style so the layout does not shift.
  • A settings page at Configuration > Media > Grout Image for site-wide defaults (base URL, colours, size, format).

Grout API endpoints used

Type URL pattern Avatar https://grout.in/avatar/{name}.{format}?size=128&background= random&color=f0e9e9&rounded=true&bold=false Placeholder https://grout.in/placeholder/{W}x{H}.{format}?text=John+Doe&bg=random&color=000000

No API key is required.

Requirements

  • Drupal 11 or later
  • The drupal:media and drupal:field core modules

Installation

Install as you would any Drupal module. See Installing Drupal Modules for details.

composer require drupal/grout_image
drush en grout_image

Configuration

  1. Navigate to Configuration > Media > Grout Image (/admin/config/media/grout-image).
  2. Set the Grout API base URL (default: https://grout.in; change only when using a self-hosted Grout instance).
  3. Configure the site-wide default avatar size, background colour, text colour, and image format. These apply whenever no per-formatter override is set.

Field formatter

  1. On a content type (or media type) that has an entity_reference field pointing to media entities, go to Manage display.
  2. Set the formatter for the media reference field to Grout Fallback.
  3. In the formatter settings:
    • Choose Fallback type: Avatar (initials) or Placeholder (solid colour).
    • Choose the Image style — the fallback image will be generated at the same output dimensions as that style. For crop/resize styles (e.g. Scale and Crop) the exact pixel dimensions are used; for scale-only styles the configured maximum dimension is used as a bounding box.
    • Optionally override background colour, text colour, and image format.
    • Choose the View mode used to render the real media entity when the field is populated.

Twig usage

The filter and function are available in any Twig template once the module is enabled.

{# Avatar — pass the entity label as the name #}
<img src="{{ node.label|grout_avatar({size: 200, rounded: true}) }}" alt="{{ node.label }}"> 

{# Placeholder — width × height, optional text and colours #}
<img src="{{ grout_placeholder(300, 450, {text: node.label, bg: '1a1a2e'}) }}" alt="{{ node.label }}"> 

Available options for grout_avatar:

Option Default Description size module default (128) Square size in pixels background module default Hex colour without # color module default Text colour hex without # rounded true Circular avatar bold true Bold initials format module default (png) png, jpg, or webp

Available options for grout_placeholder:

Option Default Description text — Text label drawn on the placeholder bg module default Background hex without # color module default Text colour hex without # format module default (png) png, jpg, or webp

Overriding defaults in settings.php

$config['grout_image.settings']['base_url'] = 'https://grout.example.com';
$config['grout_image.settings']['default_bg'] = '1a1a2e';
$config['grout_image.settings']['default_color'] = 'ffffff';
$config['grout_image.settings']['default_size'] = 200;
$config['grout_image.settings']['default_format'] = 'webp';

Troubleshooting

The fallback image does not appear when the field is empty. Confirm that the formatter is set to Grout Fallback on the correct view mode in Manage display and that caches have been rebuilt (drush cr).

The fallback image is a different size than the real image. Choose an image style that produces fixed output dimensions (e.g. Scale and Crop). Scale-only styles do not have deterministic output dimensions; the module uses the configured maximum dimension as an approximation.

I see a broken image icon instead of a Grout placeholder. Check that the Grout base URL is reachable from the server and that there is no firewall blocking outbound requests to grout.in.

Maintainers

Current maintainers for this project:

Depends on

Dependencies of the latest stable release

  • field Drupal core
  • media Drupal core
  • system Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Mar 2026
Latest release
5 months ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

Version Type Core Release date
1.0.0 Stable 10–11 Mar 25, 2026
1.0.x-dev Dev 10–11 Mar 16, 2026