{# The `random_id` ensures that each instance of the shortcode has a "unique" id #} {# allowing individual interactive elements (like toggles) to function correctly. #} {# This avoids conflicts when multiple instances of the shortcode are used. #} {%- set random_id = get_random(end=100000) -%} {%- set colocated_path = page.colocated_path | default(value="") -%} {%- set relative_default_path = colocated_path ~ default_src -%} {%- set relative_toggled_path = colocated_path ~ toggled_src -%} {%- set default_meta = get_image_metadata(path=relative_default_path, allow_missing=true) -%} {%- if not default_meta -%} {%- set default_meta = get_image_metadata(path=default_src, allow_missing=true) -%} {%- set default_image_path = default_src -%} {%- else -%} {%- set default_image_path = relative_default_path -%} {%- endif -%} {%- set toggled_meta = get_image_metadata(path=relative_toggled_path, allow_missing=true) -%} {%- if not toggled_meta -%} {%- set toggled_meta = get_image_metadata(path=toggled_src, allow_missing=true) -%} {%- set toggled_image_path = toggled_src -%} {%- else -%} {%- set toggled_image_path = relative_toggled_path -%} {%- endif -%} {%- set lazy_loading = lazy_loading | default(value=true) -%}