fix: Images on iOS are cropped weird (#1840)

* force sync decoding on images

* use decode() to load the image

* add comment
This commit is contained in:
soxa 2025-01-28 22:30:54 +01:00 committed by GitHub
parent 965e482ea3
commit bd84b8bf88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -133,8 +133,12 @@ export const useMediaHelper = ({ src, srcSet: srcSetIntital, topLevel, tab }) =>
// hack
// if it's not a video it will throw an error, so we can assume it's an image
const img = new window.Image()
img.onload = () => setIsImage(true)
img.src = src
img.decode().then(() => { // decoding beforehand to prevent wrong image cropping
setIsImage(true)
}).catch((e) => {
console.error('Cannot decode image', e)
})
}
video.src = src