Repository navigation
Update codeinwp/optimole-sdk to 1.3.0, fixing mirrored top-corner crops - #1230
Merged
Merged
Conversation
SDK 1.3.0 fixes the swapped Position::NORTH_EAST / NORTH_WEST values. Image sizes registered with a top-corner crop (['left','top'], ['right','top']) were cropped toward the opposite corner; they now crop toward the corner WordPress asked for. Flip the two test assertions that pinned the old output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
Updates
codeinwp/optimole-sdkfrom 1.2.4 to 1.3.0.composer.jsonnow requires^1.3. The lock was updated withcomposer update codeinwp/optimole-sdk, so no other package changed.1.3.0 contains two SDK fixes: Codeinwp/optimole-php-sdk#3 (corner gravity,
cropresize type) and Codeinwp/optimole-php-sdk#4 (watermark offsets).What changes in the plugin's output:
Top-corner crops now use the right corner. In 1.2.4,
Position::NORTH_EASTwasnoweandNORTH_WESTwasnoea. The CDN readsnoeaas top right andnoweas top left, so these were swapped.to_optml_crop()(inc/traits/normalizer.php:304,306) mapsadd_image_size()crops['left','top']toNORTH_WESTand['right','top']toNORTH_EAST. Every resize that goes throughto_optml_crop()used to crop toward the opposite top corner (URL replacer, tag replacer, offload, DAM). Bottom corners and edges were already right.200×100, crop['left','top'], DAM…/dam:1/w:200/h:100/g:noea/rt:fill/q:auto/id:…/9.jpg(top right)…/dam:1/w:200/h:100/g:nowe/rt:fill/q:auto/id:…/9.jpg(top left)200×200, crop['right','top']…/w:200/h:200/rt:fill/g:nowe/q:mauto/…/sample-test.jpg(top left)…/w:200/h:200/rt:fill/g:noea/q:mauto/…/sample-test.jpg(top right)The live CDN proof is in optimole-php-sdk#3. There, with only a left/right crop,
g:noeareturns the same pixels asg:ea.Watermark offsets. 1.2.4 dropped the scale and the y offset when an earlier offset was 0. A site with a stored legacy
wm_id > 0and a scale with zero offsets now sendswm:<id>:<opacity>:<position>:0:0:<scale>instead ofwm:<id>:<opacity>:<position>(inc/url_replacer.php:402). optimole-php-sdk#4 found that the CDN removes URL watermarks from remote images, so visitors see no difference.What doesn't change:
noea/nowe, labelled correctly. The allow-lists ininc/settings.php:368-369andinc/abilities.php:66-67hold the same set of strings before and after.to_optml_watermark()(inc/traits/normalizer.php:344,346) also uses the two constants, but nothing calls it.cropresize type. The plugin never uses it: every resize it builds isResizeTypeProperty::FILL. If a site'soptml_image_args/optml_default_cropfilter returns'crop', 1.3.0 sends it asfillwith a silenced deprecation notice and doesn't throw.Tests changed: two assertions pinned the old, wrong output:
tests/test-dam.php:252:['left','top']expectsg:nowe(wasg:noea)tests/test-media.php:335:['right','top']expectsg:noea(wasg:nowe)tests/test-replacer.phpcompares against the constants, so it needed no change.How to test the changes in this Pull Request:
add_image_size( 'top_left', 200, 100, [ 'left', 'top' ] );, and render an image at that size.g:nowe(it wasg:noeabefore this PR), and the image should be cropped toward its top-left corner.[ 'right', 'top' ]: you should getg:noeaand a top-right crop.Other information:
Local runs, PHP 8.0, WordPress latest:
developmentwith SDK 1.2.4 and on this branch.developmentand on this branch. All areinclude()paths toassets/build/*files I hadn't built locally; CI builds them.🤖 Generated with Claude Code