Skip to content

v0.2.0

@simon-mundy simon-mundy tagged this 06 May 03:07
Adds a canonical thumbnail-variant constant and a thin convenience
method so CMS UIs don't have to hard-code the variant name or wrap
url() in their own try/catch.

  StorageInterface::THUMBNAIL_VARIANT  // = 'admin-thumb'
  StorageInterface::thumbnailUrl(string $path): ?string

The method is implemented as a Thumbnail trait that wraps
url($path, self::THUMBNAIL_VARIANT) and returns null when the variant
isn't registered (swallowing InvalidArgumentException). All four
adapters (InMemoryStorage, LocalFilesystem, S3, CloudflareImages)
mix in the trait — uniform behaviour across backends.

Adapters with non-default thumbnail resolution (e.g. URL transforms
without an existence check) can opt out of the trait and implement
the method directly.

BC: adds an abstract method to StorageInterface — any external
implementer of the interface needs to add the method (acceptable
pre-1.0).

Tests: 4 new tests covering the convenience on InMemoryStorage
(registered variant, missing variant, missing key, constant
exposure). 187 tests total (3 skipped require S3 env).
Assets 2
Loading