attempt to fix img shift
This commit is contained in:
parent
e63609a7c1
commit
d46ae03598
|
@ -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>
|
||||
const img = new window.Image()
|
||||
img.onload = () => setIsImage(true)
|
||||
img.onerror = () => setIsImage(false)
|
||||
img.src = src
|
||||
const video = document.createElement('video')
|
||||
video.onloadeddata = () => setIsVideo(true)
|
||||
video.onerror = () => setIsVideo(false)
|
||||
video.src = src
|
||||
|
||||
return () => {
|
||||
img.onload = null
|
||||
img.onerror = null
|
||||
img.src = ''
|
||||
video.onloadeddata = null
|
||||
video.onerror = null
|
||||
video.src = ''
|
||||
}
|
||||
}, [src, setIsImage, setIsVideo, showMedia, isVideo, embed])
|
||||
|
|
Loading…
Reference in New Issue