Skip to content
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

fix(ui): prefer adminThumbnail even if file is non-image #11948

Merged
merged 2 commits into from
Apr 7, 2025

Conversation

akhrarovsaid
Copy link
Contributor

What?

This PR relaxes the mimeType checks in the thumbnail and file cell components to accommodate an adminThumbnail even if the file is a non-image. This is useful when, for example, using an adminThumbnail function to retrieve or generate thumbnails for files that are non-images such as videos.

Why?

To prioritize an admin thumbnail if/when available on file cells and upload field thumbnails in both edit and list views.

How?

By relaxing the mimeType checks in the Thumbnail component and instead lifting that responsibility on the caller of this component. Some of these checks were not needed as the best-fit helper utility function will automatically select the thumbnailURL if available or revert to the original url if no best-fit is found.

Demo of admin thumbnail being loaded on non-image while still selecting best-fit size for images:
chrome_2025-04-01_18-56-25

@akhrarovsaid akhrarovsaid changed the title Fix/prefer adminthumbnail fix(ui): prefer adminThumbnail even if file is non-image Apr 1, 2025
@PatrikKozak PatrikKozak self-requested a review April 7, 2025 17:41
@PatrikKozak PatrikKozak self-assigned this Apr 7, 2025
Copy link
Contributor

@PatrikKozak PatrikKozak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akhrarovsaid I like this change! Thank you!

@PatrikKozak PatrikKozak merged commit 7721025 into payloadcms:main Apr 7, 2025
80 of 81 checks passed
@akhrarovsaid akhrarovsaid deleted the fix/prefer-adminthumbnail branch April 7, 2025 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants