Skip to content

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
developfrom
fix/2401-godam-image-current-url
Open

subodhr258 wants to merge 1 commit into
developfrom
fix/2401-godam-image-current-url

Conversation

@subodhr258

Copy link
Copy Markdown
Collaborator

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.

  1. Which URL the block prints (assets/src/blocks/godam-image/render.php:40-50)
    The saved url attribute 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's wp_get_attachment_url filter, which returns the CDN URL for GoDAM-managed images.
    if ( $godam_attachment_id ) {
    	$godam_current_src = (string) wp_get_attachment_image_url( $godam_attachment_id, 'full' );
    	if ( '' !== $godam_current_src ) {
    		$godam_src = $godam_current_src;
    	}
    	...
    Check: the saved width and height are 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> has height:auto, so the browser uses the real image's shape once it loads. The lookup still runs between rtgodam_before_attachment_lookup and rtgodam_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 is https://19e0ltinav.gdcdn.us/gtet5fff0k/GoDAM-Screenshot.webp?v=v3.

Block src printed today
Picked from the Media Library tab https://preprod.godam.rt.gw/wp-content/uploads/2026/11/GoDAM-Screenshot.png (local file, original version)
Picked from the GoDAM tab https://19e0ltinav.gdcdn.us/gtet5fff0k/GoDAM-Screenshot.webp?v=v2 (older version)

After. Both blocks should print the ?v=v3 CDN URL. This is covered by unit tests that render the real render.php. No recording yet: both local test sites were held by other sessions when this PR was opened.

How to test

  1. On a site with a GoDAM API key, upload an image in Media > Add New and wait until it shows as transcoded.
  2. Add a GoDAM Image block to a page and pick the image from the Media Library tab. Publish.
  3. View the page and inspect the image: src is the gdcdn.us URL, not wp-content/uploads.
  4. Replace the image in GoDAM with a different file. Reload the page without editing it: the new image shows.
  5. Delete the attachment and reload: the block still prints the saved URL.

Risk

risk: medium because it changes what every GoDAM Image block prints on the front end.

…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
@subodhr258 subodhr258 added the risk: medium Agent QA plus a human spot check label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium Agent QA plus a human spot check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant