Grav CMS – Prepare Media/Images

Grav has a caching mechanism that automatically generates thumbnails. Still it is advisable to reduce the original size of the images. I use two tools to achieve this:

find . -iname '*.jpg' -exec convert \{} -verbose -resize 2048x2048\> \{} \;
exiftool -all= *

The above command rescales all images to maximum width or height of 2048 (preserving the aspect ratio) and removes all EXIV Information.

Another task is to generate a .meta.yaml file for each picture. Unfortunately Grav has no mechanism to achieve this out of the box. However a small script can help:

for f in *.jpg
do
echo "Creating metadata file for jpg file - $f"
echo "alt_text: " > "$f.meta.yaml"
done

Leave a comment

Your email address will not be published. Required fields are marked *