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

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