Return renditions for the images inside an article body - #240
Merged
Merged
Conversation
Article pages still load full-size originals. The lead photo is almost always inline in the body rather than in featured_image: the CMS editor inserts it there, and WordPress did too. All 30 of the latest articles do this. featured_image_variants therefore never reaches it. The article detail now carries content_image_variants: renditions for each inline <img>, keyed by the wp-content path exactly as the body references it. About half of those references are WordPress resized copies (photo-1024x683.jpg). These resolve to the original's renditions, but only when the aspect ratio matches within 2%, so a square-cropped thumbnail is never replaced with the uncropped photo. The lookup is served from the same in-memory index, so it adds no queries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019EcFyy8aqNnUd75CDPY6Bx
This was referenced Oct 1, 2026
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.
Why
Article pages still load full-size originals. The lead photo is almost always inline in
content, not infeatured_image; that's true for all 30 of the latest articles. The CMS editor inserts it there, and WordPress did too. Sofeatured_image_variants(#239) never reaches the image readers actually see on an article page.Change
GET /v1/articles/{slug}gainscontent_image_variants: a map from each inline image's wp-content path, exactly ascontentreferences it (URL-decoded, no host, no query), to that image's renditions.<img src>with a regexp, since bodies are WordPress-era markup mixed with shortcodes, and decodes HTML entities before lookup.photo-1024x683.jpg). These resolve to the original's renditions only if the aspect ratio matches within 2%. WordPress also made square-cropped thumbnails, and replacing one with the uncropped photo would change the picture, not just its sharpness.featured_image_variants, so it adds no queries. Omitted when no inline image has renditions.Scalene side: it rebuilds a
srcseton body images afterstripDimensions(follow-up PR, after DrexelTriangle/Scalene#130).Verified
TestIndexForContentcovers originals, query strings, single-quotedsrcinside[caption],&in paths, a 1024×683 copy resolving to its 3:2 original, a 150×150 crop not resolving, and unrendered or hotlinked images being skipped.go test -race ./...andgo vet ./...pass. Swagger is regenerated.🤖 Generated with Claude Code
https://claude.ai/code/session_019EcFyy8aqNnUd75CDPY6Bx