Resize Images

In Grav CMS, you can resize blog post images directly in Markdown, through Twig templates, or via plugins in Grav 2 / Admin2.

1. In Markdown (Per Image)

Append media actions as query parameters to the image path inside your blog post's .md file:

• Resize to fit within dimensions (preserves aspect ratio):

MARKDOWN
![Alt text](photo.jpg?resize=800,450)
• Resize and crop to exact dimensions (centered, no background padding):
![Alt text](photo.jpg?cropZoom=800,450)
• Force exact dimensions (may stretch/distort):
![Alt text](photo.jpg?forceResize=800,450)

2. In Twig Templates (For Blog Layouts / Featured Images)

In your blog item or post template, call media methods on page.media:

• Crop and resize a specific image:

TWIG
 {{ page.media['photo.jpg'].cropZoom(800, 450).html('Alt text')|raw }} 

• Resize while keeping aspect ratio:

TWIG

{{ page.media['photo.jpg'].resize(800, 450).html('Alt text')|raw }}

3. In Grav 2 / Admin2

• Visual cropping in Admin2: Install the Image Crop Plugin for Grav Admin2 to crop images directly from the Page Media panel or Media Manager and save a copy or replace the original.

• Shrink on upload: Plugins like Bildkompression compress/shrink images right after upload in Grav Admin 2.

For full parameter options and media filters, see the Grav Media Documentation.