Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add support for fallback images for the Figure Twig template #196

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/ui/atoms/Figure/Figure.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* @param string $alt
* @param string $caption
* @param boolean $lazy
* @param boolean $lazy_fallback
* Define if a fallback image should be added for SEO purpose.
* @param 'cover'|'contain'|'fill'|'none' $fit
* Define how the image will fit.
* @param boolean $absolute
Expand Down Expand Up @@ -114,6 +116,14 @@
<figure {{ html_attributes(attributes) }}>
<div {{ html_attributes(inner_attributes) }}>
<img {{ html_attributes(img_attributes) }} />
{% if lazy and lazy_fallback %}
{% set img_noscript_attributes = img_attributes|without(['data_src', 'data_ref'])|merge({
src: img_attributes.data_src,
}) %}
<noscript>
<img {{ html_attributes(img_noscript_attributes) }}>
</noscript>
{% endif %}
</div>
{% if caption is defined %}
{% block caption %}
Expand Down
Loading