Conversation
Signed-off-by: Marco Luzi <dev@luzimarco.ch>
Signed-off-by: Marco Luzi <dev@luzimarco.ch>
Signed-off-by: Marco Luzi <dev@luzimarco.ch>
Signed-off-by: Marco Luzi <dev@luzimarco.ch>
Signed-off-by: Marco Luzi <dev@luzimarco.ch>
Signed-off-by: Marco Luzi <dev@luzimarco.ch>
Signed-off-by: Marco Luzi <dev@luzimarco.ch>
Signed-off-by: Marco Luzi <dev@luzimarco.ch>
Signed-off-by: Marco Luzi <dev@luzimarco.ch>
Add a real-WordPress integration lane as its own Composer project under tests/Integration (PHPUnit 9.6 + wp-phpunit + polyfills), kept separate so WordPress core never collides with Laravel's global helpers (both define __()). Runs via 'composer test:integration' against the DDEV WordPress core and a dedicated wordpress_test DB locally, and a matrix (wp 6.5 + latest) with a MySQL service in CI. Root static-analysis/lint skip the isolated lane.
wp_get_attachment_image_src() can return false even for an image attachment; guard it so find() honors its documented null-on-miss contract instead of accessing offsets on false.
WpImageResolver resolves a raster attachment at a named size into a ResolvedImage (src/width/height/alt), returning null for a missing attachment. Binds AttachmentRepository to the WordPress implementation.
Branch on mime before the raster path: an SVG resolves with isSvg true and null width/height/srcset, straight from its URL. Adds SVG-capable seeding to the drift-lane harness (direct insert, since WordPress blocks SVG uploads by default).
Raster images carry WordPress' srcset for the requested size; a size with no candidates and SVG sources both yield null.
ResponsiveSizes is a pure helper: an explicit sizes override wins, else auto when auto-sizing is enabled, else null. The resolver delegates to it on the raster path.
FocalPointPosition is a pure helper mapping fractional focal coordinates to a CSS object-position style, or null when disabled or incomplete. The resolver applies it to both raster and SVG sources.
OnDemandSizeGenerator creates a registered size that does not yet exist, using only front-end-safe media APIs (wp_get_image_editor, not the admin-only intermediate-size helpers). It caps generations per request and swallows every failure, degrading to the closest available source rather than fataling. The resolver invokes it on the raster path.
Swaps the container's default ImageResolver from NullImageResolver to WpImageResolver and registers OnDemandSizeGenerator as a singleton so the per-request generation cap spans a request. NullImageResolver stays as a boot-safe fallback. Updates the image-component and service-provider specs for the new default binding.
…probe Live testing on a real GD-backed WordPress showed AVIF was never activating despite the server being able to encode it. Two independent bugs in WpAvifSupport, both invisible to the fast lane (no WordPress loaded), each forcing isSupported() to false: 1. Probe source PNG was grayscale+alpha. Some GD builds (e.g. 2.3.3) reject it in imagecreatefromstring(), so wp_get_image_editor()->load() failed before any AVIF encode was attempted. Swap it for a verified 1x1 truecolor RGBA PNG (still a hardcoded byte string, so the probe stays GD-independent for Imagick-only builds). 2. cachedVerdict() read get_transient()'s "not found" false as a cached unsupported verdict, so on any site without a persistent object cache (the default) the probe never ran and never stored a real value — AVIF was dead on arrival. Cache a '1'/'0' string sentinel instead; a missing transient now resolves to null and re-probes. Regression coverage: - tests/Unit: assert the probe source is a truecolor PNG (byte check, environment-independent). - tests/Integration (real WP): an absent transient re-runs the probe, and a stored verdict is reused without re-probing. Spec updated to document both constraints.
Signed-off-by: Marco Luzi <dev@luzimarco.ch>
Signed-off-by: Marco Luzi <dev@luzimarco.ch>
Signed-off-by: Marco Luzi <dev@luzimarco.ch>
Signed-off-by: Marco Luzi <dev@luzimarco.ch>
Signed-off-by: Marco Luzi <dev@luzimarco.ch>
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.
No description provided.