diff --git a/README.md b/README.md index 95f9371..e28ffd3 100644 --- a/README.md +++ b/README.md @@ -278,7 +278,7 @@ The layout template has a commented out header tag with that when enabled will m This uses an include to generate a picture element with multiple sources with webp falling back to jpeg. use this example code to add an image to any page -if the image is empty uses a **fallback image** from **placeholder.com** - this can be update on line 21 of `_includes/responsiveImage.twig` +if the image is empty uses a **fallback image** from **placeholder.com** - this can be update on line 5 of `_includes/responsiveImage.twig` ```twig {{ include('_includes/responsiveImage', { @@ -317,6 +317,10 @@ if the image is empty uses a **fallback image** from **placeholder.com** - this } }, ], + figureClass: null, + figureStyle: null, + pictureClass: null, + caption: null, attributes: { alt: image.altText ?? image.title ?? null, class: '', diff --git a/templates/_blocks/hero/standardHero.twig b/templates/_blocks/hero/standardHero.twig index dcb4414..084dc66 100644 --- a/templates/_blocks/hero/standardHero.twig +++ b/templates/_blocks/hero/standardHero.twig @@ -36,6 +36,10 @@ } }, ], + figureClass: null, + figureStyle: null, + pictureClass: null, + caption: null, attributes: { alt: image.altText ?? image.title ?? null, class: 'object-cover z-0 w-full h-full lg:min-h-[450px] md:min-h-[375px] min-h-[300px]', @@ -44,34 +48,6 @@ }, }, with_context = false) }} - {# {% set transforms = { - '(max-width: 767px)': { - width: 767, - height:300, - mode: 'crop', - quality: 80, - }, - '(max-width: 1199px)': { - width: 1200, - height:375, - mode: 'crop', - quality: 80, - }, - '(min-width: 1200px)': { - width: 1920, - height:450, - mode: 'crop', - quality: 80, - }, - } %} - {% set attributes = { - class: [ - 'object-cover z-0 w-full h-full lg:min-h-[450px] md:min-h-[375px] min-h-[300px]', - ], - loading:'lazy', - alt: heroImage.altText ?? heroImage.title ?? null, - } %} - {{ craft.images.pictureMedia(heroImage, transforms, null, attributes) }} #} {# hero content #}
diff --git a/templates/_includes/news-listing-article.twig b/templates/_includes/news-listing-article.twig index 2731439..886131a 100644 --- a/templates/_includes/news-listing-article.twig +++ b/templates/_includes/news-listing-article.twig @@ -50,6 +50,10 @@ } }, ], + figureClass: null, + figureStyle: null, + pictureClass: null, + caption:null, attributes: { alt: image.altText ?? image.title ?? null, class: '', diff --git a/templates/_includes/responsiveImage.twig b/templates/_includes/responsiveImage.twig index 758f5c7..ac204aa 100644 --- a/templates/_includes/responsiveImage.twig +++ b/templates/_includes/responsiveImage.twig @@ -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 ?? {} -%} -#} - - - - - - {# - 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 %} - - {# webp source #} - {% set cropWebp = transform.crop|merge({ - 'format': 'webp' }) %} - - {% endfor %} - - - {{ attributes.alt }} - \ No newline at end of file +{% 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 %} + + {# webp source #} + {% set cropWebp = transform.crop|merge({ + 'format': 'webp' }) %} + + {% endfor %} + + {# + use the final crop in the transforms array + as the default + #} + {% set defaultCrop = transforms|last %} + {% set defaultCrop = defaultCrop.crop %} + {{ attributes.alt|striptags }} + + + {# image caption #} + {% if caption is defined and caption != null%} +
+ {{ caption }} +
+ {% endif %} +
\ No newline at end of file