-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨feat(image shortcodes): add lazy loading (#116)
Additionally sets the `alt` parameters as optional and cleans HTML output.
- Loading branch information
Showing
9 changed files
with
41 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
{% set meta = get_image_metadata(path=src, allow_missing=true) %} | ||
{%- set meta = get_image_metadata(path=src, allow_missing=true) -%} | ||
{%- set lazy_loading = lazy_loading | default(value=true) -%} | ||
|
||
{% if full_width | default(value=false) %} | ||
<div class="full-width"> | ||
{% endif %} | ||
<img class="dimmable-image" src="{{ get_url(path=src) }}" {% if alt %}alt="{{ alt }}" {% endif %} {% if meta.width %}width="{{ meta.width }}" {% endif %} {% if meta.height %}height="{{ meta.height }}" {% endif %}/> | ||
<img class="dimmable-image" src="{{ get_url(path=src) }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}{% if meta.width %} width="{{ meta.width }}"{% endif %}{% if meta.height %} height="{{ meta.height }}" {% endif %}/> | ||
{% if full_width | default(value=false) %} | ||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
{% set light_meta = get_image_metadata(path=light_src, allow_missing=true) %} | ||
{% set dark_meta = get_image_metadata(path=dark_src, allow_missing=true) %} | ||
{% if full_width | default(value=false) %} | ||
{%- set light_meta = get_image_metadata(path=light_src, allow_missing=true) -%} | ||
{%- set dark_meta = get_image_metadata(path=dark_src, allow_missing=true) -%} | ||
{%- set lazy_loading = lazy_loading | default(value=true) -%} | ||
|
||
{%- if full_width | default(value=false) -%} | ||
<div class="full-width"> | ||
{% endif %} | ||
<img src="{{ get_url(path=light_src) }}" {% if alt %}alt="{{ alt }}" {% endif %} {% if light_meta.width %}width="{{ light_meta.width }}" {% endif %} {% if light_meta.height %}height="{{ light_meta.height }}" {% endif %} class="img-light"> | ||
<img src="{{ get_url(path=dark_src) }}" {% if alt %}alt="{{ alt }}" {% endif %} {% if dark_meta.width %}width="{{ dark_meta.width }}" {% endif %} {% if dark_meta.height %}height="{{ dark_meta.height }}" {% endif %} class="img-dark"> | ||
{%- endif -%} | ||
<img src="{{ get_url(path=light_src) }}"{% 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 %} class="img-light"> | ||
<img src="{{ get_url(path=dark_src) }}"{% 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 %} class="img-dark"> | ||
{% if full_width | default(value=false) %} | ||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
{% set meta = get_image_metadata(path=src, allow_missing=true) %} | ||
{%- set meta = get_image_metadata(path=src, allow_missing=true) -%} | ||
{%- set lazy_loading = lazy_loading | default(value=true) -%} | ||
|
||
<div class="full-width"> | ||
<img {% if src %}src="{{ get_url(path=src) }}" {% endif %} {% if alt %}alt="{{ alt }}" {% endif %} {% if meta.width %}width="{{ meta.width }}" {% endif %} {% if meta.height %}height="{{ meta.height }}" {% endif %}/> | ||
<img src="{{ get_url(path=src) }}"{% if alt %} alt="{{ alt }}"{% endif %}{% if meta.width %} width="{{ meta.width }}"{% endif %}{% if meta.height %} height="{{ meta.height }}"{% endif %}{% if lazy_loading %} loading="lazy"{% endif %}/> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
{%- set default_meta = get_image_metadata(path=default_src, allow_missing=true) -%} | ||
{%- set hovered_meta = get_image_metadata(path=hovered_src, allow_missing=true) -%} | ||
{%- set lazy_loading = lazy_loading | default(value=true) -%} | ||
|
||
<div class="image-hover-container {% if full_width | default(value=false) %}full-width{% endif %}"> | ||
<div class="image-hover-container{% if full_width | default(value=false) %} full-width{% endif %}"> | ||
<div class="image-default"> | ||
<img src="{{ get_url(path=default_src) }}" alt="{{ default_alt }}" | ||
width="{{ default_meta.width }}" height="{{ default_meta.height }}"> | ||
<img src="{{ get_url(path=default_src) }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if hovered_alt %} alt="{{ default_alt }}"{% endif %}{% if default_meta.width %} width="{{ default_meta.width }}"{% endif %}{% if default_meta.height %} height="{{ default_meta.height }}"{% endif %}> | ||
</div> | ||
<div class="image-hovered"> | ||
<img src="{{ get_url(path=hovered_src) }}" alt="{{ hovered_alt }}" | ||
width="{{ hovered_meta.width }}" height="{{ hovered_meta.height }}"> | ||
<img src="{{ get_url(path=hovered_src) }}"{% if hovered_alt %} alt="{{ hovered_alt }}"{% endif %}{% if hovered_meta.width %} width="{{ hovered_meta.width }}"{% endif %}{% if hovered_meta.height %} height="{{ hovered_meta.height }}"{% endif %}> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
{% set meta = get_image_metadata(path=src, allow_missing=true) %} | ||
{%- set meta = get_image_metadata(path=src, allow_missing=true) -%} | ||
{%- set lazy_loading = lazy_loading | default(value=true) -%} | ||
|
||
{% if full_width | default(value=false) %} | ||
<div class="full-width"> | ||
{% endif %} | ||
<img class="invertible-image" {% if src %}src="{{ get_url(path=src) }}" {% endif %} {% if alt %}alt="{{ alt }}" {% endif %} {% if meta.width %}width="{{ meta.width }}" {% endif %} {% if meta.height %}height="{{ meta.height }}" {% endif %}/> | ||
{% if full_width | default(value=false) %} | ||
<img class="invertible-image" src="{{ get_url(path=src) }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}{% if meta.width %} width="{{ meta.width }}"{% endif %}{% if meta.height %} height="{{ meta.height }}" {% endif %}/> | ||
{%- if full_width | default(value=false) -%} | ||
</div> | ||
{% endif %} | ||
{%- endif -%} |