1
0
Fork 0

Fix unknown media not working

This commit is contained in:
Lim Chee Aun 2023-09-13 18:10:20 +08:00
parent 61e1a5042f
commit f02cd50d7b
2 changed files with 8 additions and 6 deletions

View file

@ -103,7 +103,11 @@ function Media({ media, to, showOriginal, autoAnimate, onClick = () => {} }) {
[to],
);
const isImage = type === 'image' || (type === 'unknown' && previewUrl);
const isVideoMaybe =
type === 'unknown' &&
/\.(mp4|m4a|m4p|m4b|m4r|m4v|mov|webm)$/i.test(remoteMediaURL);
const isImage =
type === 'image' || (type === 'unknown' && previewUrl && !isVideoMaybe);
const parentRef = useRef();
const [imageSmallerThanParent, setImageSmallerThanParent] = useState(false);
@ -221,7 +225,7 @@ function Media({ media, to, showOriginal, autoAnimate, onClick = () => {} }) {
)}
</Parent>
);
} else if (type === 'gifv' || type === 'video') {
} else if (type === 'gifv' || type === 'video' || isVideoMaybe) {
const shortDuration = original.duration < 31;
const isGIF = type === 'gifv' && shortDuration;
// If GIF is too long, treat it as a video

View file

@ -779,7 +779,7 @@ body:has(#modal-container .carousel) .status .media img:hover {
position: relative;
background-clip: padding-box;
}
.status :is(.media-video, .media-audio)[data-formatted-duration] .media-play {
.status :is(.media-video, .media-audio) .media-play {
pointer-events: none;
width: 44px;
height: 44px;
@ -797,9 +797,7 @@ body:has(#modal-container .carousel) .status .media img:hover {
border-radius: 70px;
transition: all 0.2s ease-in-out;
}
.status
:is(.media-video, .media-audio)[data-formatted-duration]:hover:not(:active)
.media-play {
.status :is(.media-video, .media-audio):hover:not(:active) .media-play {
transform: translate(-50%, -50%) scale(1.1);
background-color: var(--bg-color);
box-shadow: 0 0 16px var(--drop-shadow-color),