-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
68 additions
and
84 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,55 +1,55 @@ | ||
{# | ||
// set some default transforms that can be overridden in the template - this isn't done yet | ||
{%- set transforms = transforms|default([]) -%} | ||
{%- set srcset = transformedImages|map(image => "#{image.getUrl()} #{image.width}w") -%} | ||
{%- set attributes = attributes ?? {} -%} | ||
#} | ||
|
||
|
||
<picture> | ||
|
||
|
||
{# | ||
use the final crop in the transforms array | ||
as the default | ||
#} | ||
{% set defaultCrop = transforms|last %} | ||
{% set defaultCrop = defaultCrop.crop %} | ||
|
||
{# set fallBack image for when the field is empty #} | ||
{% set fallbackImage = 'https://placehold.co/' ~ defaultCrop.width ~ 'x' ~ defaultCrop.height ~ '/dfe4f7/bababa' %} | ||
|
||
|
||
{% for transform in transforms %} | ||
{# jpeg source #} | ||
{% set crop = transform.crop %} | ||
<source | ||
media="{{ transform.mq }}" | ||
srcset="{{ image.url(crop) ?? fallbackImage }}" | ||
width="{{ transform.crop.width ?? null }}" | ||
height="{{ transform.crop.height ?? null }}" | ||
type="image/jpeg" | ||
> | ||
{# webp source #} | ||
{% set cropWebp = transform.crop|merge({ | ||
'format': 'webp' }) %} | ||
<source | ||
media="{{ transform.mq }}" | ||
srcset="{{ image.url(cropWebp) ?? fallbackImage }}" | ||
width="{{ transform.crop.width ?? null }}" | ||
height="{{ transform.crop.height ?? null }}" | ||
type="image/webp" | ||
> | ||
{% endfor %} | ||
|
||
|
||
<img | ||
src="{{ image.url(defaultCrop) ?? fallbackImage }}" | ||
alt="{{ attributes.alt }}" | ||
class="{{ attributes.class }}" | ||
width="{{ defaultCrop.width }}" | ||
height="{{ defaultCrop.height }}" | ||
loading="{{ attributes.loading }}" | ||
{{ attributes.dataAttributes|raw }}/> | ||
</picture> | ||
{% set defaultCrop = transforms|last %} | ||
{% set defaultCrop = defaultCrop.crop %} | ||
|
||
{# set fallBack image for when the field is empty #} | ||
{% set fallbackImage = 'https://placehold.co/' ~ defaultCrop.width ~ 'x' ~ defaultCrop.height ~ '/dfe4f7/bababa' %} | ||
|
||
|
||
<figure class="{{ figureClass ?? null }}" style="{{ figureStyle ?? null }}"> | ||
<picture class="{{ pictureClass ?? null }}"> | ||
{% for transform in transforms %} | ||
{# jpeg source #} | ||
{% set crop = transform.crop %} | ||
<source | ||
media="{{ transform.mq }}" | ||
srcset="{{ image.url(crop) ?? fallbackImage }}" | ||
width="{{ transform.crop.width ?? null }}" | ||
height="{{ transform.crop.height ?? null }}" | ||
type="image/jpeg" | ||
> | ||
{# webp source #} | ||
{% set cropWebp = transform.crop|merge({ | ||
'format': 'webp' }) %} | ||
<source | ||
media="{{ transform.mq }}" | ||
srcset="{{ image.url(cropWebp) ?? fallbackImage }}" | ||
width="{{ transform.crop.width ?? null }}" | ||
height="{{ transform.crop.height ?? null }}" | ||
type="image/webp" | ||
> | ||
{% endfor %} | ||
|
||
{# | ||
use the final crop in the transforms array | ||
as the default | ||
#} | ||
{% set defaultCrop = transforms|last %} | ||
{% set defaultCrop = defaultCrop.crop %} | ||
<img | ||
src="{{ image.url(defaultCrop) ?? fallbackImage }}" | ||
alt="{{ attributes.alt|striptags }}" | ||
class="{{ attributes.class }}" | ||
width="{{ defaultCrop.width ?? null }}" | ||
height="{{ defaultCrop.height ?? null }}" | ||
loading="{{ attributes.loading }}" | ||
style="{{ attributes.style ?? null }}" | ||
{{ attributes.dataAttributes|raw }}/> | ||
</picture> | ||
|
||
{# image caption #} | ||
{% if caption is defined and caption != null%} | ||
<figcaption class="block px-4 py-2 italic border-b text-14 text-grayBrand border-text-grayBrand-light"> | ||
{{ caption }} | ||
</figcaption> | ||
{% endif %} | ||
</figure> |