Skip to content

Instantly share code, notes, and snippets.

@zachleat
Created September 5, 2019 13:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachleat/f43c3d461df1e6ba3272cea6e4f7b50d to your computer and use it in GitHub Desktop.
Save zachleat/f43c3d461df1e6ba3272cea6e4f7b50d to your computer and use it in GitHub Desktop.
Experimenting with a Nunjucks shortcode for images in Eleventy
<!-- throws an error, missing [alt] attribute -->
{% img src="img/9a93578a.png", loading="lazy" %}
<!-- local img source, outputs a standard <img> tag -->
{% img src="img/9a93578a.png", alt="zachleat’s Avatar", loading="lazy" %}
<!-- remote img source -->
<!-- download using avatar-local-cache, outputs <picture> with webp and png fallback -->
{% img src="https://www.gravatar.com/avatar/e1899004c71c7043343196103e210be3?default=404", alt="zachleat’s Avatar", loading="lazy" %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment