Skip to main content

lektor image resize plugin

PyPI version Downloads Linting Python package Upload Python Package MIT License

This plugin generates JPG and WEBP Images and Thumbnails in predefined sizes for any images in your Lektor content. The difference between this plugin and the lektor thumbnail filter is that this plugin is converting all images and you don't need to have any references to the images in your templates.

TL;DR: What does this plugin do?

  • It will generate JPEG images in the sizes you configured of all images in your Lektor content using imagemagic.
  • It will generate WEBP images in the same sizes using imagemagic.

Usage

Use this plugin if you want to be able to link to full-size images in your content, but still want thumbnails to be generated for the link itself. For example, you may have an image called waffle.jpg, and to link to it in the content (not the template), but also show a thumbnail. All images will be converted to webp using Pillow.

You can use the images like that:

<!-- Simple example -->
<a href="waffle.jpg"><img src="waffle-small.jpg" /></a>

<!-- example with srcset -->
<a href="waffle-small.webp">
  <img src="waffle-small.webp"
    srcset="waffle-small.webp  640w,   // Viewport bis zu 640
            waffle-medium.webp 1280w,  // Viewport größer als 1280
            waffle-woowee.webp 1920w"  // Viewport größer als 1920
  />
</a>

Installation

To install the plugin, add lektor-image-resize to your plugins from the command line and create a config file:

# add the plugin to lektor
lektor plugins add lektor-image-resize

If you have trouble, see the plugin installation section of the Lektor documentation.

Create a 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.

Here is a example config file:

[small]
width = 640
height = 360

[medium]
height = 720

[woowee]
width = 1920

Will take a file called waffle.jpg and create the files waffle-small.jpg, waffle-medium.jpg and waffle-woowee.jpg as well as waffle-small.webp, waffle-medium.webp and waffle-woowee.webp All the files will be created, regardless of whether the original file is smaller, so you can link without worrying whether a file will exist or not. If the original file is smaller than the width you have specified, the file will only be copied, and will not be resized.

The max_width/max_height parameters work like for the Lektor thumbnail command.

Good to know

There is a filter plugin avaliable at lektor-image-filter available, that can help you to use the image in all configured sizes,

Metadata

Release files for lektor-image-resize 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lektor-image-resize 1.0.0
File Size Uploaded Provenance Actions
lektor-image-resize-1.0.0.tar.gz 5.5 kB Without provenance Details for lektor-image-resize-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lektor-image-resize 1.0.0
File Interpreter ABI Platform Actions
lektor_image_resize-1.0.0-py3-none-any.whl Python 3 none any Details for lektor_image_resize-1.0.0-py3-none-any.whl

Total release size: 11.4 kB

Release files / lektor-image-resize-1.0.0.tar.gz

Download URL lektor-image-resize-1.0.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2df994397c245f50624b94a764bc6550bd416c1ece60e7a36ffbd561c5c719d6
BLAKE2b-256 checksum
How to use checksums
11974a25477a318b7468b2dad036cb288be9c526b7ba74b5682915ec82d62415
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_resize-1.0.0-py3-none-any.whl

Download URL lektor_image_resize-1.0.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef4ee974100715ca2c22d52a2c10efa103ebacc4095a2fb5da64d1e46bfe2145
BLAKE2b-256 checksum
How to use checksums
30230fe2522cba9ee43bd1f662fd6fc42b979caeafb811a1559684463f0f4d8e
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-resize 1.0.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page