Repository navigation
v0.10.0
Fixed
- The three thumbnail drivers now answer the same way on the cases the adapter contract tests had listed as known deviations (#58), and
THUMBNAIL_KNOWN_DEVIATIONSis empty.PolloraThumbnailDrivergives the same file name for/a.jpganda.jpg.BunnyThumbnailDriverencodes?and#in the key of the original, sosizeOf()finds the class ofwhat?.jpgagain.PolloraThumbnailDriver::sizeOf()andImgproxyThumbnailDriver::sizeOf()answer only the name of a declared size, and the imgproxy driver no longer recognises the URL of a size it refuses (default). The names and URLs of the keys that were valid (no leading slash, no?or#) are unchanged. SizeGeometryno longer divides by zero for an original WordPress recorded with no dimensions: a scale or a contain keeps the dimensions it was given (no geometric resize) andcoverRegion()keeps the whole original, soDeclaredSizes::downsize()and the drivers'url()never throwDivisionByZeroError.
Changed
- BREAKING:
PolloraThumbnailDrivertakes the declared sizes (ImageSizes) as a third constructor argument andImgproxyThumbnailDriveras its third, before the base URL (new ImgproxyThumbnailDriver($signer, $config, $sizes, $baseUrl, $bucket)), to recognise only declared sizes asBunnyThumbnailDriveralready does.ThumbnailDrivers::make()andDeclaredSizespass them; only code that builds these drivers by hand changes.
||||||| d54194b
- The unit suite loads its stand-in for WP-CLI from
tests/bootstrap.phpinstead oftests/Pest.php, which the integration suite also loads (a real WordPress must not find aWP_CLIthat is not WP-CLI). No change to the package.
Security
- A size signature is never made with an empty key (#53). With an empty
app.key(or a blank salt) the HMAC of a file name was computable by anyone, who could then have the declared sizes made for any original.SizedFileNamenow throwsInvalidMediaConfigurationException::emptySigningKey()when the key it resolves is empty or blank, with a message that says what to set (APP_KEY, or the WordPress salts); the key is still resolved when a signature is made, so a key known late works, and an installation with a key sees no change: the file names and signatures are what they were (the signature stays cut to 12 hexadecimal digits, which a name already issued depends on).
Added
- An integration suite (
tests/Integration,composer test:integration) that runs against a real WordPress: the upload directory moved to the wrapper and the public URL, an uploaded image stored with the sizes WordPress and the module make through the real image editors, the URL of a declared size and the file made when it is first asked for, the focal point meta written over REST (an editor only, a point out of range refused) with the covers made around it, the legacy URLs replaced in the content, and the private flag read from the table. It is not part of the defaultpestrun; the harness's optionalWordPress integrationjob starts it. - A focal point per image (#18). The post meta
_pollora_focal_point({x, y}, fractions of the original from 0 to 1, kept to a thousandth) is declared withregister_post_meta()and a schema, so it is read and written over REST by a user who can edit the attachment.FocalPointvalidates it (a value that is not a point is no point),FocalPointsreads it typed, once per media ($media->focalPoints()->for($id),set(),clear()), and the newpollora/media/focal_pointfilter has the last word. With a point,SizeGeometry::coverRegion(..., $anchor, $focal)centres the region on it, clamped to the edges, instead of using the anchor; dimensions,srcsetand the sizes that do not crop are unchanged.ImageSizeSpecgets an optional$focalandfocusedOn(); the point is part offingerprint()and of the signature, and the file of a cover around one is namedphoto-card-600x400-f0250_0750-{signature}.webp, so moving the point never leaves a stale copy and the fallback route makes the file from its name alone, with no lookup. The files of a size of an image without a point keep their names. Changing or removing the point deletes the files made around the previous one and makes theeager()covers around the new one;thumbs pruneremoves the crops around a point that is not the image's any more; the files go with the media. imgproxy and Bunny cannot hold a point in a preset or a class: a cover of an image with a point is made by the module whatever the driver (so the fallback route is now registered with these drivers too), a private media stays kept from the service.ThumbnailRouteaccepts the new segment.DeclaredSizes::make(),fileFor()andexistingFiles()take an optional focal point,SizePruneran optional$focalOfclosure,SizedFileName::parse()returns the point asfocal. No editing screen yet.