Skip to content

Recognize media type via Content-Type #2075

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Soxasora
Copy link
Member

@Soxasora Soxasora commented Apr 7, 2025

Description

Fixes #1433
Instead of loading media beforehand to recognize if it's an image or a video, this method fetches Content-Type header to recognize it.
This fixes AVIF images that loads as video by following its MIME type rather than trying to load it as video/image.

Screenshots

This is an AVIF image downloaded from stacker.news after Imgproxy processing, it gets rendered as an image, before it would've rendered as video on browsers like Chrome

Additional Context

Fetching headers should be faster than loading media beforehand as it doesn't fetch the whole file.

Using video.duration didn't make the cut because Imgproxy creates AVIFs that have Infinity duration

Checklist

Are your changes backwards compatible? Please answer below:
Yes, it falls back to the original method if HEAD fetch fails

On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
7, tested on Chrome (it happens way more here)

For frontend changes: Tested on mobile, light and dark mode? Please answer below:
n/a

Did you introduce any new environment variables? If so, call them out explicitly here:
n/a

@Soxasora Soxasora changed the title Recognize media type via Content-Type Use video tag only if duration is meaningful Apr 10, 2025
@Soxasora Soxasora changed the title Use video tag only if duration is meaningful Recognize media type via Content-Type Apr 13, 2025
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.

AVIF images are rendered as video
1 participant