-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
resize_image
built-in fx to make image URLs
- Loading branch information
1 parent
74521c0
commit 4f3e58d
Showing
1 changed file
with
4 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
{% if src %} | ||
{# If the image's URL is internal to the site... #} | ||
{% if src is not starting_with("http") %} | ||
{# ... then prepend the site's base URL to the image's URL. #} | ||
{% set src = config.base_url ~ src %} | ||
{# ... then convert the page's colocated_path attribute to a string so it can be concatenated... #} | ||
{% set colocated_path = page.colocated_path | as_str %} | ||
{# ... and use `resize_image` to get image's URL for colocated blog posts and non-colocated blog posts. #} | ||
{% set image = resize_image(path=colocated_path ~ src, width=5000, height=5000, op="fit") %} | ||
{% endif %} | ||
<img src="{{ src | safe }}"{% if alt %} alt="{{ alt }}"{% endif %} class="{% if position %}{{ position }}{% else -%} center {%- endif %}" {%- if style %} style="{{ style | safe }}" {%- endif %} decoding="async" loading="lazy"/> | ||
{% endif %} |