Skip to content

Kirby 4.5.0

thumbs

Set default configuration for thumbs

Presets

You can define option presets for thumbs:

/site/config/config.php
return [
    'thumbs' => [
        'presets' => [
            'default' => ['width' => 1024, 'quality' => 80],
            'blurred' => ['blur' => true]
        ]
    ]
];

To be used with the $file->thumb() method. Learn more ›

Srcsets

/site/config/config.php
return [
  'thumbs' => [
    'srcsets' => [
      'default' => [
        '800w' => ['width' => 800, 'quality' => 80],
        '1024w' => ['width' => 1024, 'quality' => 80],
        '1440w' => ['width' => 1440, 'quality' => 80],
        '2048w' => ['width' => 2048, 'quality' => 80]
      ]
  ]
  ]
];

To be used with the $file->srcset() method. Learn more ›

Auto-orient

Automatically rotate images based on their exif orientation data.

return [
  'thumbs' => [
    'autoOrient' => true
  ]
];

Quality

The default JPEG compression quality for all thumbnails

return [
  'thumbs' => [
    'quality' => 80
  ]
];

Format

You can set a default format for thumbs in your config file to convert all images unless you override the format option in the thumb method.

/site/config/config.php
<?php

return [
  'thumbs' => [
    'format' => 'webp'
  ]
];

This is only recommended if you really find yourself converting 90% of your files to that format anyway. Otherwise you will need to override the default quite a lot.

Thumbs driver

Kirby comes with drivers for GD Lib (gd) and ImageMagick (im), which can be used out of the box. The default thumbs driver is gd.

You can also define your own custom thumbs drivers.

return [
  'thumbs' => [
    'driver' => 'im'
  ]
];

Additional options for the ImageMagick driver

bin

If the ImageMagick convert binary is not correctly linked, you can set the absolute path to the binary here.

return [
  'thumbs' => [
    'driver' => 'im',
    'bin' => 'convert'
  ]
];

interlace

JPEGs can be set to interlace mode with this option

return [
  'thumbs' => [
    'driver' => 'im',
    'interlace' => true
  ]
];
Since 4.2.0

threads

If you are converting a lot of big images with ImageMagick it can get slow.

Use this option to configure the threads ImageMagick can use to benefit from capable hardware. (default is 1)

return [
  'thumbs' => [
    'driver' => 'im',
    'threads' => 2
  ]
];