Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

image_styles_builder

116 sites Security covered
View on drupal.org

Image Styles Builder allows a developer to quickly create image styles in bulk, based on definition files.

The goal of this package is to enable the rapid creation of image styles by declaring them in a custom module file definition (YAML).

The primary aim of Image Styles Builder is to allow Frontend to declare many necessary image-styles and provide to Backend
developers a way to document and define those styles to be generated or flushed at any moment.

Use Image Styles Builder if

  • You need to generate Drupal Images Styles quickly without using the UI
  • You receive a definition/lists of Images Styles to generate from another co-worker/team
  • You have a lot of Images Styles to generate at once
  • You want to be able to generate Images Styles and Rollback them easily
  • You want to be able to fetch a collection of Image Styles in Twig (must previously be defined with this module)

Getting Started

We highly recommend you to install the module using `composer` as a dev dependency.

Caution, If you desire to use the Twig Filter on production, then install the module a s root dependency instead of dev dependency.

composer require --dev drupal/image_styles_builder

Usage

Generating & Rollback of Image Styles

  1. Create your own custom module that will contain your image styles definition(s).
  2. Create your derivative definition file yourmodule.image_styles_builder_derivatives.yml:
    default:
      id: default
      label: Default
      suffix: dft
      styles:
        9_2_64x14:
          effects:
            -
              type: 'scale_and_crop'
              data:
                width: 64
                height: 14
        9_2_640x142:
          effects:
            -
              type: 'scale_and_crop'
              data:
                width: 640
                height: 142
        9_2_640x142_webp:
          effects:
            -
              type: 'scale_and_crop'
              data:
                width: 640
                height: 142
            -
              type: 'image_convert'
              data:
                extension: 'webp'
        16_10_64x40:
          effects:
            -
              type: 'scale_and_crop'
              data:
                width: 64
                height: 40
        16_10_128x80:
          effects:
            -
              type: 'scale_and_crop'
              data:
                width: 128
                height: 80
            -
              type: 'image_scale'
              data:
                width: 64
        original_64:
          effects:
            -
              type: 'image_scale'
              data:
                width: 64
    
  3. Run the generate command to build your image styles in bulk.
    drush isb:gen
    
  4. (optional) Export the new image styles configuration.
  5. (optional) Rollback previously generated Image styles with the flush command.
    drush isb:flush
    

Fetch Image Styles in Twig

Once generated, you may want to fetch your image styles by definition. This is possible throughout the isb_image_styles Twig function.

Twig Example code

{% styles = isb_image_styles('default') %}
{{ styles|json_encode }}

Caution, If you desire to use the Twig Filter on production, then install the module a s root dependency instead of dev dependency.

Exposed Drush Commands

This module is shipped with drush commands to assist you in your workflow.

Generate Command

The Generate command will create new image styles (and skip existing ones) by discovering all the derivatives files (*.image_styles_builder_derivatives.yml)

drush isb:gen

Flush Command

The Flush command will delete every image styles that have been created during a previous isb:gen.
The discovery operation will be based on all the derivatives files (*.image_styles_builder_derivatives.yml):

drush isb:flush

Versions

Drupal Core Image Styles Builder 8.x none 9.x 1.0.x 10.x 1.1.x 11.x 1.1.x

Dependencies

The Drupal 9, Drupal 10 & Drupal 11 version of Image Styles Builder requires nothing !
Feel free to use it.

Image Styles Builder requires PHP 7.4+ to works properly. We recommend updating to at least
PHP 8.1 if possible, and ideally PHP 8.2, which is supported as of Drupal 10.x.

Similar modules

  • Image Style Generate allows a site administrator to quickly create image styles in bulk, based on a defined set of rules and patterns.

Supporting organizations

This project is sponsored by Antistatique. We are a Swiss Web Agency, Visit us at www.antistatique.net or Contact us.

Activity

Total releases
4
First release
Apr 2025
Latest release
2 months ago
Release cadence
93 days
Stability
100% stable

Release Timeline

Releases

Version Type Release date
1.1.6 Stable Jan 26, 2026
1.1.5 Stable Nov 7, 2025
1.1.4 Stable Jun 3, 2025
1.1.3 Stable Apr 23, 2025