From 93fd472f353d004ae399eb1d5619539a7efe30c5 Mon Sep 17 00:00:00 2001 From: xAlpharax <42233094+xAlpharax@users.noreply.github.com> Date: Tue, 12 Aug 2025 06:50:12 +0300 Subject: Major changes and the start of my post on a rust week. Changes to be committed: modified: .gitignore modified: config.toml modified: content/posts/rust.md modified: templates/404.html modified: templates/index.html new file: templates/shortcodes/image.html new file: static/css/critical.css deleted: rsync_to_testing --- templates/shortcodes/image.html | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 templates/shortcodes/image.html (limited to 'templates/shortcodes/image.html') diff --git a/templates/shortcodes/image.html b/templates/shortcodes/image.html new file mode 100644 index 0000000..8b1a006 --- /dev/null +++ b/templates/shortcodes/image.html @@ -0,0 +1,46 @@ +{# /templates/shortcodes/image.html (Version 7 - The Final Quality Fix) #} + +{# --- Manually check for required 'src' and 'alt' parameters --- #} +{% if not src %} + {{ throw(message="The 'src' parameter is required for the image shortcode.") }} +{% endif %} +{% if not alt %} + {{ throw(message="The 'alt' parameter is required for the image shortcode.") }} +{% endif %} + +{# --- Get optional parameters, with sensible defaults --- #} +{% set lazy = lazy | default(value=true) %} +{% set fetch = fetch | default(value="auto") %} +{% set quality = quality | default(value=60) %} {# <-- New: Set a default quality #} + +{# --- Let Zola process the image into ALL necessary formats and sizes --- #} +{% set image_meta = get_image_metadata(path=src) %} + +{# Create small versions (PNG and WebP) with higher compression #} +{% set image_small_png = resize_image(path=src, width=383, op="fit_width", quality=quality) %} +{% set image_small_webp = resize_image(path=src, width=383, op="fit_width", format="webp", quality=quality) %} + +{# Create large versions (PNG and WebP) with higher compression #} +{% set image_large_png = resize_image(path=src, width=682, op="fit_width", quality=quality) %} +{% set image_large_webp = resize_image(path=src, width=682, op="fit_width", format="webp", quality=quality) %} + + + {# --- MODERN FORMATS FIRST (WebP) --- #} + + + + {# --- FALLBACK FORMATS (PNG) --- #} + + + + {# --- FINAL FALLBACK --- #} + {{ alt }} + -- cgit v1.2.3