mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-23 00:56:23 +01:00
Sometimes it returns a preview image without dimenions
This commit is contained in:
parent
a0d2037007
commit
0efa39b825
1 changed files with 16 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue