Reference

Guide

$file->thumb()

Creates a modified version of images The media manager takes care of generating those modified versions and putting them in the right place. This is normally the /media folder of your installation, but could potentially also be a CDN or any other place.

$file->thumb(array|null|string $options = null): Kirby\Cms\FileVersion|Kirby\Cms\File

Parameters

Name Type Default Description
$options array|null|string null

Return type

Kirby\Cms\FileVersion|Kirby\Cms\File

Options

You can use the following options in the options array (values are the default values):

$options = [
  'autoOrient' => true,
  'crop'       => false,
  'blur'       => false,
  'grayscale'  => false,
  'height'     => null,
  'quality'    => 90,
  'width'      => null,
];

You can define presets of options in your config.php. Learn more ›

Example

if($image = $page->image()):
    echo $image->thumb([
      'width'   => 300,
      'height'  => 200,
      'quality' => 80
    ])->html();
endif;

Source code

kirby/src/Cms/FileModifications.php#L159