Skip to content

fix: resolve thumbnailURL to direct cloud storage URLs - #17347

Open
thedanielmark wants to merge 1 commit into
payloadcms:mainfrom
thedanielmark:fix/thumbnail-url-cloud-storage
Open

fix: resolve thumbnailURL to direct cloud storage URLs#17347
thedanielmark wants to merge 1 commit into
payloadcms:mainfrom
thedanielmark:fix/thumbnail-url-cloud-storage

Conversation

@thedanielmark

Copy link
Copy Markdown

What?

Fixes #12659

When using cloud storage with adminThumbnail set to a string size name (for example 'thumbnail'), thumbnailURL could resolve to /api/{collection}/file/... instead of the direct CDN or S3 URL. This affected admin list thumbnails and any API response that relied on thumbnailURL.

Why?

Two independent bugs in core:

  1. appendUploadSelectFields
    For string adminThumbnail, the list-view select only projected sizes.<name>.filename, not .url. Without the stored URL in the projection, the thumbnailURL afterRead hook falls back to building a local API path from the filename.

  2. generateFilePathOrURL
    When serverURL is unset, which is common for relative-URL deployments, urlOrPath.startsWith(serverURL || '') becomes startsWith(''). That is always true, so external URLs were treated as same-origin and discarded in favor of the local file path.

Related: #15988 adds generateFileURL hooks on thumbnailURL in plugin-cloud-storage. That work is complementary. It regenerates URLs on read when generateFileURL is configured. This PR fixes select projection and external URL detection in core.

How?

  • Add url: true to the sizes.<adminThumbnail> select in appendUploadSelectFields, matching the behavior of the non-string adminThumbnail branch.
  • In generateFilePathOrURL, only treat urlOrPath as same-origin when serverURL is actually configured.

Verification

  • pnpm test:unit appendUploadSelectFields generateFilePathOrURL
  • pnpm test:int storage-s3
  • pnpm test:int plugin-cloud-storage
  • pnpm test:int uploads

Include sizes.<adminThumbnail>.url in list-view select projections and
treat external URLs correctly when serverURL is unset.

Fixes payloadcms#12659
@thedanielmark thedanielmark changed the title fix(payload): resolve thumbnailURL to direct cloud storage URLs fix: resolve thumbnailURL to direct cloud storage URLs Jul 15, 2026
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.

s3Storage plugin uploads to S3 but admin panel and API sPAYPUB-290till serve local URLs despite disableLocalStorage: true

1 participant