Skip to content

About

Automatic scaling of (too large) images in Plone sites

Resources

Stars

1 star

Watchers

9 watching

Forks

Repository files navigation

collective.autoscaling

Tests Meta

This package allows automatic scaling of too large images in Plone sites. Images can be either Image content type or any Image field on content types.

This is totally transparent to the user (except if you choose to show message).

There is also a view (@@resize-images) that you can call to scale existing images (under the context of your choice), for example:

Settings

  • Enable automatic scaling (yes / no)
  • Maximum height at which images will be automatically resized (in pixels)
  • Maximum width at which images will be automatically resized (in pixels)
  • JPEG quality
  • Show information message to user when images have been resized (yes / no)

Use case

  1. You configure collective.autoscaling to have images with maximum size of height 800px / width 1200px.
  2. One of your user uploads a really big image: height 2000px / width 4000px.
  3. This image will be resized to height 600px / width 1200px (aspect ratio is of course preserved).

Limitations

This add-on works only with Dexterity content types.

Version 2.x supports Plone 6.1 on Python 3.10 to 3.13, and Plone 6.2 on Python 3.10 to 3.14. For Plone 4.3 to 6.0, use collective.autoscaling 1.x.

Translations

This product has been translated into

  • English
  • French
  • Norwegian
  • Portuguese

Installation

Add collective.autoscaling to the dependencies of your project (pyproject.toml, or requirements.txt with the Plone constraints), install it, restart Plone and activate the add-on in Site Setup > Add-ons.

Development

Requires uv. This installs Plone 6.2.3 in .venv (use PLONE_VERSION=6.1.6 make install for another version) and the prek git hook:

make install
make start          # Plone on http://localhost:8080 (admin / admin)

Create a Classic UI site from the browser, then activate collective.autoscaling.

Tests

Tests run through tox, as the CI does. The robot scenarios run in headless Chrome, which must be installed (Node.js too, for rfbrowser init):

make test                                   # Plone 6.2.3
uvx --with tox-uv tox -e py312-plone61      # one Plone / Python combination
make test-all                               # lint, every combination, dependencies

Integration tests only, without tox:

.venv/bin/zope-testrunner --test-path=src -s collective.autoscaling

Lint

make check          # format then lint (pyupgrade, isort, black, zpretty, flake8...)

.editorconfig, .flake8, .gitignore, .pre-commit-config.yaml, tox.ini, .github/ and the tool sections of pyproject.toml are generated by plone.meta: change .meta.toml, then run uvx --from plone.meta config-package --no-commit --branch current ..

Contribute

License

The project is licensed under the GPLv2.

About

Automatic scaling of (too large) images in Plone sites

Resources

Stars

1 star

Watchers

9 watching

Forks

Releases

Used by

Contributors

Languages