Coverage for website/utils/templatetags/thumbnail.py: 83.33%
6 statements
« prev ^ index » next coverage.py v7.6.7, created at 2025-08-14 10:31 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2025-08-14 10:31 +0000
1"""Thumbnail template tags."""
3from django import template
5from utils.media.services import get_thumbnail_url
7register = template.Library()
10@register.simple_tag
11def thumbnail(path, size, absolute_url=False):
12 """Generate a thumbnail for a path.
14 This templatetag provides us with a way of getting a thumbnail
15 directly inside templates. See the documentation
16 of :func:`get_thumbnail_url` for a more information.
17 :param path: The path or ImageField we want an thumbnail from,
18 this field MUST NEVER be a user input.
19 :param size: The size we want from settings.THUMBNAIL_SIZES.
20 :param absolute_url: True if we want the full url including the scheme and domain.
21 :return: The thumbnail url.
22 """
23 return get_thumbnail_url(path, size, absolute_url)