Repository navigation
GoDAM Image block: show the image's current URL, not the one saved when it was picked - #2402
Open
subodhr258 wants to merge 1 commit into
Open
subodhr258 wants to merge 1 commit into
subodhr258 wants to merge 1 commit into
Conversation
…en it was picked The block printed the URL saved in the editor, which goes stale: the local uploads file for an image now served from the GoDAM CDN, or an older version of a replaced image. Render the attachment's current URL and keep the saved one only as the fallback for a deleted attachment. Fixes #2401
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.
What and why
A GoDAM Image block shows the image URL that was saved in the block when the image was picked. It never looks the URL up again. So a block whose image came from the Media Library tab can keep showing the local
wp-content/uploads/...file after GoDAM has a CDN copy. A block whose image was later replaced keeps showing the old version. This PR makes the block print the attachment's current URL when the page is viewed. It falls back to the saved URL only when the attachment is gone.Closes #2401.
Where to look
Everything else is a test stub made configurable plus new unit tests.
assets/src/blocks/godam-image/render.php:40-50)The saved
urlattribute was used as-is, and the attachment URL was read only when nothing was saved. Now the attachment's current URL comes first.wp_get_attachment_image_url()goes through GoDAM'swp_get_attachment_urlfilter, which returns the CDN URL for GoDAM-managed images.widthandheightare deliberately left as they are. WordPress's stored size can be stale after a GoDAM replace (on preprod, attachment 392 stores 1030 x 207 while the current image is 2560 x 1800), and the<img>hasheight:auto, so the browser uses the real image's shape once it loads. The lookup still runs betweenrtgodam_before_attachment_lookupandrtgodam_after_attachment_lookup, so integrations that switch site context keep working.UI evidence
Before (preprod,
develop). https://preprod.godam.rt.gw/test-url/ has two GoDAM Image blocks, both for attachment 392. The attachment's current URL ishttps://19e0ltinav.gdcdn.us/gtet5fff0k/GoDAM-Screenshot.webp?v=v3.srcprinted todayhttps://preprod.godam.rt.gw/wp-content/uploads/2026/11/GoDAM-Screenshot.png(local file, original version)https://19e0ltinav.gdcdn.us/gtet5fff0k/GoDAM-Screenshot.webp?v=v2(older version)After. Both blocks should print the
?v=v3CDN URL. This is covered by unit tests that render the realrender.php. No recording yet: both local test sites were held by other sessions when this PR was opened.How to test
srcis thegdcdn.usURL, notwp-content/uploads.Risk
risk: mediumbecause it changes what every GoDAM Image block prints on the front end.