feat: img shortcode with resize_image and lazy loading
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
{# Image shortcode with width-based resize and lazy loading.
|
||||||
|
Usage in markdown:
|
||||||
|
{{ img(src="team/Olli.jpg", width=400, alt="Dr. Riemann") }}
|
||||||
|
{{ img(src="carousel/page1.jpg", width=1920, alt="Praxis") }}
|
||||||
|
Class is optional, e.g. class="float-right". #}
|
||||||
|
|
||||||
|
{%- set source_path = "static/images/" ~ src -%}
|
||||||
|
{%- set resized = resize_image(path=source_path, width=width, op="fit_width", quality=85) -%}
|
||||||
|
<img
|
||||||
|
src="{{ resized.url }}"
|
||||||
|
width="{{ resized.width }}"
|
||||||
|
height="{{ resized.height }}"
|
||||||
|
alt="{{ alt | default(value="") }}"
|
||||||
|
{%- if class %} class="{{ class }}"{% endif %}
|
||||||
|
loading="lazy"
|
||||||
|
>
|
||||||
Reference in New Issue
Block a user