Skip to main content

This plugin automatically generates thumbnails for any images in your Lektor content. The difference between this plugin and the `thumbnail` filter is that this is geared towards content, i.e. you don't need to have any references to the images in your templates at all.

Project description

Lektor Thumbnail Generator

This plugin automatically generates thumbnails for any images in your Lektor content. The difference between this plugin and the thumbnail filter is that this is geared towards content, i.e. you don't need to have any references to the images in your templates at all.

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 cat.jpg, and to link to it in the content (not the template), but also show a thumbnail.

You can do that like so:

<a href="cat.jpg"><img src="cat-small.jpg" /></a>

Installation

To install the plugin, just add lektor-thumbnail-generator to your plugins from the command line:

lektor plugins add lektor-thumbnail-generator

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

Then, create a config file called configs/thumbnail-generator.ini and add a few sections for images. The section names can be whatever you want, the final images will be called imagename-sectionname.ext. For example, this config file:

[small]
max_width = 30

[medium]
max_width = 400
max_height = 400

[woowee]
max_width = 2000

Will take a file called cat.jpg and create the files cat-small.jpg, cat-medium.jpg and cat-woowee.jpg. 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.

Unfortunately, due to the way Lektor's thumbnail system works, files will be scaled up if they're too small. The max_width/max_height parameters work like for the Lektor thumbnail command.

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

lektor-thumbnail-generator-0.3.3.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file lektor-thumbnail-generator-0.3.3.tar.gz.

File metadata

File hashes

Hashes for lektor-thumbnail-generator-0.3.3.tar.gz
Algorithm Hash digest
SHA256 f3698a48dc70f499fc164c90fdd6ace87c9f7d7199578ff30d43eb7da938477c
MD5 a5436cb75a9eb3f95b40fb9fda4f6296
BLAKE2b-256 f3b01c78223d6f49f63882246677966e5b695b020d1f22c24c95e92f6f6b8e9b

See more details on using hashes here.

File details

Details for the file lektor_thumbnail_generator-0.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for lektor_thumbnail_generator-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a24452d59d4d7f389f14df8974e00fc348cb87fcb549362bf8afcff751a23de5
MD5 1ef2597cb1950d3f2c0c32c00433c767
BLAKE2b-256 eeab2a130d1ec153936ab3f32b83ff388f7c6264f11277ca458e9ee42f5b9493

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page