Image generation helper
This project includes a simple script to generate responsive image variants.
Install dev dependencies (sharp):
npm install --save-dev sharp
Run the generator:
npm run images:build
This will generate -480, -768 and -1200 variants next to existing images in assets/img
.
How to use in templates (Eleventy shortcode):
In your page frontmatter or template, add a reference to the image basename and the shortcode will output a picture element.
Example in a template / include:
{% responsiveImage "index_hero.webp", "Alt text for hero" %}
Notes:
scripts/generate-images.js
.