Skip to content
This repository has been archived by the owner on Aug 12, 2023. It is now read-only.

A Grav plugin for resizing images when they are uploaded

License

Notifications You must be signed in to change notification settings

fredrikekelund/grav-plugin-resize-images

Repository files navigation

Grav Resize Images Plugin

This plugin is unmaintained. Feel free to fork and continue development elsewhere.

Resize images at upload time in the Grav admin

Grav provides some nifty built-in features for editing images on the fly through the use of Gregwar/Image. But there's no support yet for automatically generating responsive image alternatives at upload time rather than at request time. This plugin fixes that! It will automatically resize images that are uploaded through the Grav admin to a set of predetermined widths. This means improved performance for Grav, and less manual resizing work for you. Win-win! 🎉

Moreover, this plugin doesn't support just GD, but also Imagick, which means you'll get higher quality results than with the ImageMedium#derivatives method that can be used to generate image alternatives in theme templates.

Images that already have responsive alternatives won't be resized.

Configuration

You can customize the set of widths that your images will be resized to. By default they are 640, 1000, 1500, 2500, 3500 pixels in width. Images will never be scaled up, however, so only the widths that are smaller than the original image's will be used.

For every width, you're also able to set the JPEG compression quality. A good rule of thumb is to lower that number at higher widths - the result will still be good!

This plugin won't convert PNG's to JPEG's, so the quality number only applies to JPEG images.

To generate variations of existing images go into the admin panel and re-save the pages where those images live. Every time a page is saved (whether it's new or old), this plugin will go through all images (again, whether they are new or old) in that page, check if they have responsive variants and generate new ones if necessary.

Installation

Download the ZIP archive from GitHub and extract it to the user/plugins directory in your Grav installation.

CLI

I'm aiming to add support for CLI commands to this plugin as well, to make it easy to generate responsive image alternatives for already uploaded images.

About

A Grav plugin for resizing images when they are uploaded

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages