From 3f43e17029e864357cecff021180efd12d1f203c Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Wed, 6 Jan 2021 15:01:03 +0100 Subject: [PATCH] Make sure to not allocate the space if the featured image is the same as the site-wide image --- layouts/partials/summary-with-image.html | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/layouts/partials/summary-with-image.html b/layouts/partials/summary-with-image.html index 79cde75..05c50e1 100644 --- a/layouts/partials/summary-with-image.html +++ b/layouts/partials/summary-with-image.html @@ -1,4 +1,10 @@ {{ $featured_image := partial "func/GetFeaturedImage.html" . }} +{{ if $featured_image }} +{{ $default_image := (trim .Site.Params.featured_image "/") | relURL }} +{{ $current_image := (trim $featured_image "/") | relURL }} +{{/* Trick to avoid setting the featured image if it corresponds to the main site */}} +{{ .Scratch.Set "same_image" (eq $default_image $current_image) }} +{{ end }}
@@ -6,9 +12,7 @@ {{/* Trimming the slash and adding absURL make sure the image works no matter where our site lives */}} {{ $featured_image := (trim $featured_image "/") | absURL }} {{/* Don't put the featured image in the summary if it's the default one */}} - {{ $default_image := (trim .Site.Params.featured_image "/") | relURL }} - {{ $current_image := $featured_image | relURL }} - {{ if not (eq $default_image $current_image) }} + {{ if not (.Scratch.Get "same_image") }} {{ end }} {{ end }} -