Reference

Guide

$file->resize()

Resizes the file with the given width and height while keeping the aspect ratio.

$file->resize(int $width = null, int $height = null, int $quality = null): Kirby\Cms\File

Parameters

Name Type Default Description
$width int null
$height int null
$quality int null

Return type

Kirby\Cms\File

Example

if($image = $page->image()):
    // resize by width and height and echo the url
    echo $image->resize(300, 200);

    // adjust the quality
    echo $image->resize(300, 200, 80);

    // resize by height
    echo $image->resize(null, 200);

    // resize by width
    echo $image->resize(300);
endif;

Source code

kirby/src/Cms/FileModifications.php#L84