summaryrefslogtreecommitdiff
path: root/themes/tabi-lean/templates/shortcodes/dual_theme_image.html
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2025-09-13 14:55:15 -0600
committerAlejandro Soto <alejandro@34project.org>2025-09-13 14:55:15 -0600
commit87f85704af1fa866be83077b2b351c1fdad7c3ce (patch)
treeb49c8d49ef717e539bff6578992e692eea55d380 /themes/tabi-lean/templates/shortcodes/dual_theme_image.html
parent1a4c3216f027d6a6f36104547377b7b21faa5015 (diff)
parenta2ea06d513a5802964f8f0ef5795cec7e548ed7b (diff)
Merge commit 'a2ea06d513a5802964f8f0ef5795cec7e548ed7b' as 'themes/tabi-lean'
Diffstat (limited to 'themes/tabi-lean/templates/shortcodes/dual_theme_image.html')
-rw-r--r--themes/tabi-lean/templates/shortcodes/dual_theme_image.html45
1 files changed, 45 insertions, 0 deletions
diff --git a/themes/tabi-lean/templates/shortcodes/dual_theme_image.html b/themes/tabi-lean/templates/shortcodes/dual_theme_image.html
new file mode 100644
index 0000000..5eadc09
--- /dev/null
+++ b/themes/tabi-lean/templates/shortcodes/dual_theme_image.html
@@ -0,0 +1,45 @@
+{%- set colocated_path = page.colocated_path | default(value="") -%}
+{%- set lazy_loading = lazy_loading | default(value=true) -%}
+{%- set inline = inline | default(value=false) -%}
+
+{%- set light_class_list = "img-light" -%}
+{%- set dark_class_list = "img-dark" -%}
+{%- if inline -%}
+ {%- set light_class_list = light_class_list ~ " inline" -%}
+ {%- set dark_class_list = dark_class_list ~ " inline" -%}
+{%- endif -%}
+
+{# Handling for light mode image #}
+{%- if light_src is starting_with("http") or raw_path -%}
+ {%- set light_image_url = light_src -%}
+{%- else -%}
+ {%- set relative_light_path = colocated_path ~ light_src -%}
+ {%- set light_meta = get_image_metadata(path=relative_light_path, allow_missing=true) -%}
+ {%- if not light_meta -%}
+ {%- set light_image_url = get_url(path=light_src, cachebust=true) -%}
+ {%- else -%}
+ {%- set light_image_url = get_url(path=relative_light_path, cachebust=true) -%}
+ {%- endif -%}
+{%- endif -%}
+
+{# Handling for dark mode image #}
+{%- if dark_src is starting_with("http") or raw_path -%}
+ {%- set dark_image_url = dark_src -%}
+{%- else -%}
+ {%- set relative_dark_path = colocated_path ~ dark_src -%}
+ {%- set dark_meta = get_image_metadata(path=relative_dark_path, allow_missing=true) -%}
+ {%- if not dark_meta -%}
+ {%- set dark_image_url = get_url(path=dark_src, cachebust=true) -%}
+ {%- else -%}
+ {%- set dark_image_url = get_url(path=relative_dark_path, cachebust=true) -%}
+ {%- endif -%}
+{%- endif -%}
+
+{%- if full_width -%}
+ <div class="full-width">
+{%- endif -%}
+<img class="{{ light_class_list }}" src="{{ light_image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}{% if light_meta.width %} width="{{ light_meta.width }}"{% endif %}{% if light_meta.height %} height="{{ light_meta.height }}" {% endif %}>
+<img class="{{ dark_class_list }}" src="{{ dark_image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}{% if dark_meta.width %} width="{{ dark_meta.width }}"{% endif %}{% if dark_meta.height %} height="{{ dark_meta.height }}" {% endif %}>
+{%- if full_width -%}
+ </div>
+{%- endif -%}