Skip to content

Configuration

Jan Hermann edited this page Oct 9, 2026 · 1 revision

⚙️

Options of the bundle under imagony.thumbnails, their defaults and the registered services.

No configuration file is needed. Create config/packages/imagony.yaml only for the values you want to change. Defaults are defined in Configuration.

Symfony configuration

imagony:
    thumbnails:
        base: '%kernel.project_dir%/public/'
        folder: '%kernel.project_dir%/public/thumbnails/'
        fallback: null
        strict: null
        flags: ['shrink_only']
        formats: []
        templates:
            blog:
                path: 'images/blog/'
                height: 250
                quality: 80

Show the options, or the resulting configuration of your project:

php bin/console config:dump-reference imagony
php bin/console debug:config imagony

Options

Option Default Description
base %kernel.project_dir%/public/ Folder with source images. Paths given to thumbnail() and template path are relative to it.
folder %kernel.project_dir%/public/thumbnails/ Folder where thumbnails are generated, it is created when missing. Thumbnail::clean() removes files from it.
fallback null Image returned when a source image is missing or can not be processed. null is the built-in placeholder, an own image has to be inside base.
strict null Throw when a configured format can not be written by PHP. null follows kernel.debug, see Diagnostics.
flags ['shrink_only'] Default resize flags: fit, shrink_only, stretch, fill, exact. Flags of a template replace them.
formats [] Formats to which every thumbnail is also converted (<thumbnail>.webp, <thumbnail>.avif): webp, avif. See Converters.
templates none Named sizes used as thumbnail('name', 'image.jpg').

Template options

Option Required Description
path yes Folder with source images, relative to base.
width no Missing width or height is calculated from the aspect ratio.
height no See width.
flags no Flags for resizing, they replace the default ones.
quality no 0-100, the driver default when empty.

How configuration is merged

  • Scalars (base, folder, fallback, strict) from your file replace the defaults.
  • flags and formats from your file replace the defaults. When they are set in more files (e.g. config/packages/dev/imagony.yaml), the lists are appended.
  • templates are merged by their name, so an environment file can change only blog.height.

Services

Registered from services.yaml and console.yaml:

  • Imagony\Thumbnails\Thumbnail (public): receives the configuration, the logger (if any) and kernel.debug.
  • Imagony\Twig\ImagonyExtension: tagged twig.extension, adds thumbnail().
  • Imagony\EventListener\PlaceholderListener: kernel.request listener with priority 256, see Placeholder.
  • Imagony\Diagnostics\Environment: created by Environment::current().
  • Imagony\Commands\CheckCommand and Imagony\Commands\CleanCommand: loaded only when symfony/console is installed, see Commands.

The configuration is available as the container parameter imagony.thumbnails.

Clone this wiki locally