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

Test code for AbstractImage.get_renditions() #367

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions bakerydemo/base/templatetags/rendition_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django import template

register = template.Library()


@register.inclusion_tag("tags/renditions.html")
def renditions(image, *specs: str):
return {"renditions": image.get_renditions(*specs)}
4 changes: 2 additions & 2 deletions bakerydemo/templates/includes/card/listing-card.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{% load wagtailimages_tags %}
{% load wagtailimages_tags rendition_tags %}

<div class="listing-card">
<a class="listing-card__link" href="{{ page.url }}">
{% if page.image %}
<figure class="listing-card__image">
{% image page.image fill-180x180-c100 loading="lazy" %}
{% renditions page.image 'fill-180x180-c100' 'max-300x300' 'width-600' %}
</figure>
{% endif %}
<div class="listing-card__contents">
Expand Down
3 changes: 3 additions & 0 deletions bakerydemo/templates/tags/renditions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% for rendition in renditions.values %}
<img src="{{ rendition.file.url }}" width="{{ rendition.width }}" height="{{ rendition.height }}" alt="Filter spec: {{ rendition.filter_spec }}" />
{% endfor %}