attempt to fix img shift

This commit is contained in:
k00b 2024-09-16 12:00:15 -05:00
parent e63609a7c1
commit d46ae03598
1 changed files with 0 additions and 4 deletions

View File

@ -122,19 +122,15 @@ export const useMediaHelper = ({ src, srcSet: srcSetIntital, topLevel, tab }) =>
// make sure it's not a false negative by trying to load URL as <img> // make sure it's not a false negative by trying to load URL as <img>
const img = new window.Image() const img = new window.Image()
img.onload = () => setIsImage(true) img.onload = () => setIsImage(true)
img.onerror = () => setIsImage(false)
img.src = src img.src = src
const video = document.createElement('video') const video = document.createElement('video')
video.onloadeddata = () => setIsVideo(true) video.onloadeddata = () => setIsVideo(true)
video.onerror = () => setIsVideo(false)
video.src = src video.src = src
return () => { return () => {
img.onload = null img.onload = null
img.onerror = null
img.src = '' img.src = ''
video.onloadeddata = null video.onloadeddata = null
video.onerror = null
video.src = '' video.src = ''
} }
}, [src, setIsImage, setIsVideo, showMedia, isVideo, embed]) }, [src, setIsImage, setIsVideo, showMedia, isVideo, embed])