Skip to main content

Pelican plugin that insert thumbnails along image links

Project description

Pull Requests Welcome build status Pypi latest version License: AGPL v3

Pelican plugin that insert thumbnails along image links.

Démo page

https://chezsoi.org/lucas/blog/pages/images-libres-de-droits.html#fonts

Source Markdown: pages/images-libres-de-droits.md

Usage instructions

To enable this plugin:

  1. Install the package from Pypi: pip install pelican-plugin-image-preview-thumbnailer
  2. Add the plugin to your pelicanconf.py:
PLUGINS = [..., 'image_preview_thumbnailer']
  1. Enable it on the article / pages you wish by inserting this piece of metadata:
Image-preview-thumbnailer: $selector

$selector is a CSS selector to target HTML elements this plugin will parse and look for <a> hyperlinks. It can be for example article if your Pelican template place your pages content in <article> tags, or just body to select the whole page.

Supported link formats

Currently this plugin support preview of the following links:

  • "raw" links to GIF/JPEG/PNG images
  • links to ArtStation artwork pages
  • links to Behance artwork pages
  • links to Dafont font pages
  • links to DeviantArt artwork pages
  • links to Flickr photos
  • links to WikiArt art pages
  • links to Wikipedia/Wikimedia images

Feel free to submit PRs to add support for more image hosting websites.

Configuration

Available options:

  • IMAGE_PREVIEW_THUMBNAILER_INSERTED_HTML (optional, default: <a href="{link}" target="_blank" class="preview-thumbnail"><img src="{thumb}" class="preview-thumbnail"></a>) : the HTML code to be inserted after every link (<a>) to an image, in order to preview it
  • IMAGE_PREVIEW_THUMBNAILER_DIR (optional, default: thumbnails) : directory where thumbnail images are stored
  • IMAGE_PREVIEW_THUMBNAILER_THUMB_SIZE (optional, default: 300) : size in pixel of the generated thumbnails.
  • IMAGE_PREVIEW_THUMBNAILER_ENCODING (optional, default: utf-8) : encoding to use to parse HTML files
  • IMAGE_PREVIEW_THUMBNAILER_HTML_PARSER (optional, default: html.parser) : parse that BEautifulSoup will use to parse HTML files
  • IMAGE_PREVIEW_THUMBNAILER_CERT_VERIFY (optional, default: False) : enforce HTTPS certificates verification when sending linkbacks
  • IMAGE_PREVIEW_THUMBNAILER_REQUEST_TIMEOUT (optional, in seconds, default: 3) : time in seconds allowed for each HTTP linkback request before abandon
  • IMAGE_PREVIEW_THUMBNAILER_USERAGENT (optional, default: pelican-plugin-image-preview-thumbnailer) : the User-Agent HTTP header to use while sending notifications.

Release notes

cf. CHANGELOG.md

Features that could be implemented

  • the initial idea for this plugin was to just add 🖼️ icons on links to images, and then only display thumbnails when hovering on those links. A more basic approach of just inserting <img> tags was in the end deemed sufficient, but the original mechanism could still be implemented with a custom DEFAULT_INSERTED_HTML & adequate CSS styling.

Contributing

Contributions are welcome and much appreciated. Every little bit helps. You can contribute by improving the documentation, adding missing features, and fixing bugs. You can also help out by reviewing and commenting on existing issues.

To start contributing to this plugin, review the Contributing to Pelican documentation, beginning with the Contributing Code section.

Releasing a new version

With a valid ~/.pypirc:

  1. update CHANGELOG.md
  2. bump version in pyproject.toml
  3. poetry build && poetry publish
  4. perform a release on GitGub, including the description added to CHANGELOG.md

Linter & tests

To execute them:

pylint *.py
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

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file pelican-plugin-image-preview-thumbnailer-1.0.2.tar.gz.

File metadata

File hashes

Hashes for pelican-plugin-image-preview-thumbnailer-1.0.2.tar.gz
Algorithm Hash digest
SHA256 2fe68353ed3d3a76fffa28df739e1ad480213d14dd7ae1510f74366eae8829a8
MD5 4d81b72ef2beb98350039419e4d3e1e8
BLAKE2b-256 d506e35896d1fbee403f147632de90447573c9872017840f3e71317c07a17fab

See more details on using hashes here.

File details

Details for the file pelican_plugin_image_preview_thumbnailer-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pelican_plugin_image_preview_thumbnailer-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 de9713c04eba5055b6fae3f3b8f949d79100d9470136696054e6b9d6adcd3c3a
MD5 c2267a28aeaf972eeb01acdc8a495f34
BLAKE2b-256 28e349d8e263486a54f9fe27750af8a3fef6c85325eaaff2992ac75e9d0fc573

See more details on using hashes here.

Supported by

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