Skip to content

Update codeinwp/optimole-sdk to 1.3.0, fixing mirrored top-corner crops - #1230

Merged
selul merged 1 commit into
developmentfrom
chore/optimole-sdk-1.3.0
Nov 5, 2026
Merged

selul merged 1 commit into
developmentfrom
chore/optimole-sdk-1.3.0

Conversation

@selul

@selul selul commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

All Submissions:

Changes proposed in this Pull Request:

Updates codeinwp/optimole-sdk from 1.2.4 to 1.3.0. composer.json now requires ^1.3. The lock was updated with composer update codeinwp/optimole-sdk, so no other package changed.

1.3.0 contains two SDK fixes: Codeinwp/optimole-php-sdk#3 (corner gravity, crop resize 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_EAST was nowe and NORTH_WEST was noea. The CDN reads noea as top right and nowe as top left, so these were swapped. to_optml_crop() (inc/traits/normalizer.php:304,306) maps add_image_size() crops ['left','top'] to NORTH_WEST and ['right','top'] to NORTH_EAST. Every resize that goes through to_optml_crop() used to crop toward the opposite top corner (URL replacer, tag replacer, offload, DAM). Bottom corners and edges were already right.

    Image size Before (1.2.4) After (1.3.0)
    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:noea returns the same pixels as g: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 > 0 and a scale with zero offsets now sends wm:<id>:<opacity>:<position>:0:0:<scale> instead of wm:<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:

  • Watermark position settings. The settings screen stores the raw strings noea/nowe, labelled correctly. The allow-lists in inc/settings.php:368-369 and inc/abilities.php:66-67 hold 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.
  • The crop resize type. The plugin never uses it: every resize it builds is ResizeTypeProperty::FILL. If a site's optml_image_args/optml_default_crop filter returns 'crop', 1.3.0 sends it as fill with a silenced deprecation notice and doesn't throw.

Tests changed: two assertions pinned the old, wrong output:

  • tests/test-dam.php:252: ['left','top'] expects g:nowe (was g:noea)
  • tests/test-media.php:335: ['right','top'] expects g:noea (was g:nowe)

tests/test-replacer.php compares against the constants, so it needed no change.

How to test the changes in this Pull Request:

  1. Register a size with a top-corner crop, e.g. add_image_size( 'top_left', 200, 100, [ 'left', 'top' ] );, and render an image at that size.
  2. The Optimole URL should contain g:nowe (it was g:noea before this PR), and the image should be cropped toward its top-left corner.
  3. Do the same with [ 'right', 'top' ]: you should get g:noea and a top-right crop.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Local runs, PHP 8.0, WordPress latest:

  • Full PHPUnit suite: 519 tests and 2,050 assertions pass, both on development with SDK 1.2.4 and on this branch.
  • Without the two assertion changes: on the new SDK, the five SDK-related classes (replacer, srcset, lazyload, DAM, media; 236 tests) fail only those two assertions.
  • PHPStan: the same 6 findings on development and on this branch. All are include() paths to assets/build/* files I hadn't built locally; CI builds them.
  • phpcs: clean on the changed files.

🤖 Generated with Claude Code

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>
@pirate-bot

Copy link
Copy Markdown
Collaborator

Plugin build for 8ec3cd7 is ready 🛎️!

@selul
selul merged commit ed124d4 into development Nov 5, 2026
11 checks passed
@selul
selul deleted the chore/optimole-sdk-1.3.0 branch November 5, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants