Sometimes it returns a preview image without dimenions

pull/493/head
Lim Chee Aun 2024-04-11 17:45:19 +08:00
rodzic a0d2037007
commit 0efa39b825
1 zmienionych plików z 16 dodań i 0 usunięć

Wyświetl plik

@ -511,6 +511,22 @@ function Media({
height={height}
data-orientation={orientation}
loading="lazy"
onLoad={(e) => {
if (!hasDimensions) {
const $media = e.target.closest('.media');
if ($media) {
$media.dataset.orientation =
e.target.naturalWidth > e.target.naturalHeight
? 'landscape'
: 'portrait';
$media.style['--width'] = `${e.target.naturalWidth}px`;
$media.style[
'--height'
] = `${e.target.naturalHeight}px`;
$media.style.aspectRatio = `${e.target.naturalWidth}/${e.target.naturalHeight}`;
}
}
}}
/>
) : (
<video