image-filter
A Lektor filter to print the input image in different predefined image sizes.
This plugin is designed to work together with the lektor-image-resize Plugin.
Current Filters:
imagessrcsetwebpwill print the configured sizes aswebpto put in asrcsetelement.imagessrcwebpwill print the first configuredwebpimage name to put in asrcelement.imagessrcsetjpgwill print the configured sizes asjpgto put in asrcsetelement.imagessrcjpgwill print the first configuredjpgimage name to put in asrcelement.firstwidthwill print the first configured image width to put in awidthelement. If you use the Advanced Lektor Example we try to compute the width if no is provided,firstheightwill print the first configured image height to put in aheightelement. If you use the Advanced Lektor Example we try to compute the height if no is provided,
Configuration
You can configure the image width in the config file called configs/image-resize.ini and add
a few sections for images. The section names can be whatever you want, the
final images will be called $(imagename)-$(sectionname).jpg and $(imagename)-$(sectionname).webp.
If the width enty does not exist the entry will be ignored.
Here is a example config file:
[small]
width = 640
height = 360
[medium]
height = 720
[woowee]
width = 1920
Simple Lektor Example
Lektor Jinja2 Input
<img src="{{ 'waffle.jpg'|imagessrcjpg }}"
width="{{ 'random_string'|firstwidth }}" height="{{ ''|firstheight }}"
srcset="{{ 'waffle.jpg'|imagessrcsetjpg }}" />
Lektor HTML Output:
<img src="waffle-small.webp"
width="640" height="360"
srcset="waffle-small.webp 640w,
waffle-woowee.webp 1280w,
waffle-woowee.webp 1920w" />
-> If the width is not defined the option will be skipped in srcset!
Advanced Lektor Example
Lektor Models Definition
[fields.my_image]
label = Example Image
description = Select a Image from the Attatchments of this site. Upload one, if no one is available
type = select
source = record.attachments.images
Lektor Jinja2 Input
{% set image = record.attachments.images.get(this.my_image) %}
<img src="{{ image | imagessrcwebp }}"
width="{{ image | firstwidth }}" height="{{ image | firstheight }}"
srcset="{{ image | imagessrcsetwebp }}" />
Explaination Input:
- First we created the Jinaja2-variable
imagethat will contain our image (this.box_image) to make this example better readable. (We assume you know how to create variables in lektor) - Next line we created a html image tag with
srcandwidth - Last we created the
srcsetelement with all configured sizes.
Lektor HTML Output
<img src="waffle-small.webp"
width="640" height="360"
srcset="waffle-small.webp 640w,
waffle-medium.webp 1280w,
waffle-woowee.webp 1920w" />
-> If the width is not defined we try to compute the option based on the height entry and the source image aspect ratio.
(Please note that we added some new lines to make the example better readable and we assume that my_image: waffle.jpg comes from your .lr file, created via lektor admin menu) and is a image in 16:9 aspect ratio.
Installation
lektor plugin add lektor-image-filter
Metadata
Release files for lektor-image-filter 3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lektor-image-filter-3.0.tar.gz | 4.6 kB | Without provenance | Details for lektor-image-filter-3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lektor_image_filter-3.0-py3-none-any.whl | Python 3 | none | any | Details for lektor_image_filter-3.0-py3-none-any.whl |
Total release size: 9.7 kB
Release files / lektor-image-filter-3.0.tar.gz
| Download URL | lektor-image-filter-3.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
690c94bd6bb8a3f29666d94a7c0f934276d76edddfccd328130f32bac219aeee
|
|
BLAKE2b-256 checksum How to use checksums |
a5dfba83842845ee7c6a805b06cfc9039a9971cde05afbe08e343b065ab0e919
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Release files / lektor_image_filter-3.0-py3-none-any.whl
| Download URL | lektor_image_filter-3.0-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c074f198b61320ce585f35abf65f5a18d3f300342ab6cab5af27c2e9388c59f
|
|
BLAKE2b-256 checksum How to use checksums |
f4075b6938ffa14d2b8afe279e04cd0887f14ef02171db71ee554d430c538d73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Security for lektor-image-filter 3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.