Only show listing images if there are some
This saves a bit more space for page listings which don't have images
This commit is contained in:
parent
bd4c1a193a
commit
b0f1191d8f
2 changed files with 8 additions and 3 deletions
|
@ -263,7 +263,12 @@ class BaseListingPage(RoutablePageMixin, BaseContentPage):
|
|||
|
||||
def get_context(self, request: HttpRequest) -> dict:
|
||||
context = super().get_context(request)
|
||||
context["listing_pages"] = self.get_paginator_page()
|
||||
listing_pages = self.get_paginator_page()
|
||||
context["listing_pages"] = listing_pages
|
||||
|
||||
# Show listing images if at least 1 page has an image
|
||||
context["show_listing_images"] = any(p.list_image_url for p in listing_pages)
|
||||
|
||||
return context
|
||||
|
||||
@cached_property
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{% load wagtailcore_tags wagtail_cache util_tags %}
|
||||
|
||||
{% wagtailpagecache FRAGMENT_CACHE_TTL "listing-item" breadcrumbs %}
|
||||
{% wagtailpagecache FRAGMENT_CACHE_TTL "listing-item" breadcrumbs show_listing_images %}
|
||||
<article class="media listing-item">
|
||||
<div class="columns">
|
||||
<figure class="media-left column is-3 image-column">
|
||||
<figure class="media-left column is-{{ show_listing_images|yesno:'3,1' }} image-column">
|
||||
{% if page.list_image_url %}
|
||||
<a href="{% pageurl page %}" class="image" title="{{ page.title }}">
|
||||
<img src="{{ page.list_image_url }}" alt="{{ page.hero_image_alt }}" loading="lazy" decoding="async" referrerpolicy="no-referrer" />
|
||||
|
|
Loading…
Reference in a new issue