Skip to content

fix(templates): Media component failing when set serverURL #12214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Rot4tion
Copy link

What?

Fixes #12171

Why?

Previously, the ImageMedia component was not properly handling URL formatting when a serverURL was configured in Payload. This caused images to fail to load when using a custom serverURL. By extracting the URL handling logic into a separate utility function, we ensure consistent URL processing across both image and video components.

How?

  1. Created a new utility function getMediaUrl in src/utilities/getMediaUrl.ts that:
    • Properly checks for HTTP/HTTPS protocols
    • Handles null or undefined URL values
    • Supports cache tags to prevent caching issues
    • Uses getClientSideURL() for relative paths
  2. Updated the ImageMedia component to use this utility function instead of inline URL processing logic
  3. Updated the VideoMedia component to also use the same utility function for consistency

… if serverURL is set in Payload's config

Replaces URL construction with dedicated media URL function

Implements a new utility function for constructing media URLs, enhancing code maintainability and clarity.

Updates the ImageMedia and VideoMedia components to utilize the new function for generating source URLs, improving consistency in URL handling.
Copy link
Contributor

github-actions bot commented Apr 25, 2025

Pull Request titles must follow the Conventional Commits specification and have valid scopes.

The subject "Media component failing when set serverURL" found in the pull request title "fix(templates): Media component failing when set serverURL"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character.

feat(ui): add Button component
^    ^    ^
|    |    |__ Subject
|    |_______ Scope
|____________ Type

@Rot4tion Rot4tion changed the title fix(templates) Media component failing when set serverURL fix(templates): Media component failing when set serverURL Apr 25, 2025
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.

Website template's ImageMedia component fails if serverURL is set in Payload's config
1 participant