A Wagtail app to add a picture tag.
Project description
Wagtail Picture Tag adds a picture template tag. This is not supposed to be a solution for all situations but to be a shortcut for most.
It accepts 3 main types of filters: formats, resizing methods and sizes.
Formats
By default it will try and create JPEG, PNG, WEBP and AVIF (if available).
You may use format-jpeg, format-png, format-webp, format-gif and format-avif
There are also two format shortcuts:
photo - will create JPEG, WEBP and AVIF
transparent - will create WEBP, PNG and AVIF
Resizing
Resizing methods are the same as Wagtails with the exception that you can provide multiple filters
Sizes
Sizes are automatically generated to match resizing filters provided but can be specified for more responsive sizes.
size-250px will create sizes=”250px” size-max100-300vw size-250px will create sizes=”(max-width: 300px) 100vw, 250px”
Lazy
It also takes the argument lazy that simply adds loading=”lazy” to the HTML tag.
AVIF
Currently Willow (the image library used by Wagtail) does not support AVIF but support can be patched in by installing willowavif package.
Quick start
Install the package:
pip install wagtail-picture-tag
Add “wagtail-picture-tag” to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ... 'wagtail_picture_tag', ]Include the tag in your template:
{% load picture_tags %}Use the tag:
{% picture image photo fill-640x480 fill-320x240 %}
AVIF support
All that is needed is to install the willowavif package, it is then automatically imported and used.
Testing
Testing is done with pytest. Install and test can be done with:
pip install -r requirements.txt -r requirements.dev.txt pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wagtail-picture-tag-2.0.1.tar.gz.
File metadata
- Download URL: wagtail-picture-tag-2.0.1.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cfd71d03a4b0f5b85d7b0e2fc95f4e942ca2b43f257881c5e04cd21941fa552
|
|
| MD5 |
2daf6dba7c45aefc48ecda4c3da1e35c
|
|
| BLAKE2b-256 |
b7e2c92e29e074d6c80e12920c58c56a56f4583eb51fc744606bca31884dc128
|
File details
Details for the file wagtail_picture_tag-2.0.1-py3-none-any.whl.
File metadata
- Download URL: wagtail_picture_tag-2.0.1-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8c2f387c7776419470725ac0b4c65713d4e2c1c3f3995e5df6d01a85fcbe8c8
|
|
| MD5 |
ca9c6b9003b5185c7e4b53462f00ce07
|
|
| BLAKE2b-256 |
91fc06b0c55da57910c673a2c3a60cb7ccee61d7d17482119719bfb1aa6aa954
|