purplespider/silverstripe-clearer-thumbnails

Makes CMS and UploadField thumbnails clearer

Installs: 1 656

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 5

Forks: 2

Type:silverstripe-vendormodule

1.0.2 2023-05-19 12:36 UTC

This package is auto-updated.

Last update: 2024-10-19 15:32:48 UTC


README

This module fixes an issue in Silverstripe 4 which results in particularly tall or wide images having pixelated/blurry thumbnails in the CMS, particularly for UploadFields.

Before:

Screenshot 2021-08-06 at 09 24 31@2x

After:

Screenshot 2021-08-06 at 09 29 37@2x

It also increases the size of thumbnail images to ensure they remain crips on HiDPI/Retina displays.

Installation

  1. Install module via composer:
composer require purplespider/silverstripe-clearer-thumbnails "1.*"
  1. Perform a flush:
https://www.example.com?flush=1
  1. For Silverstripe 4: For sites with existing assets, run the generate-cms-thumbnails task to re-generate the thumbnails for the Files tab (otherwise no thumbnails will appear).
php vendor/silverstripe/framework/cli-script.php dev/tasks/MigrateFileTask only=generate-cms-thumbnails

Silverstripe 5 doesn't provide the MigrateFileTask anymore.

What exactly does this do?

It simply overrides some settings via a config file to:

  1. Change ThumbnailGenerator $method from FitMax to Fill which avoids thumbnails being generated too small and then stretched.
  2. Doubles the UploadField $thumbnail_width and $thumbnail_height from 60 to 120 to ensure thumbnails are crisp on HiDPI/Retina displays.
  3. Increases the Image $asset_preview_width and $asset_preview_height to ensure image previews in the Files area are crisp on HiDPI/Retina displays.

Notes/Tips

  • On sites with lots of images, the migration task is a resource intensive process which can take a while. Use cpulimit to limit the effect it has on the site, e.g. cpulimit -p 1234 -l 50
  • Possible issue with assets in a symlinked location not getting updated via the migration task, suggest temporarily replacing the symlink with the assets dir before running the task if you experience this.