From 4e5940900e8bec2b791798dac1ac1fd34dc5f546 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 9 Apr 2024 23:35:17 +0800 Subject: [PATCH] Pixelfed-related fixes --- src/components/media.jsx | 47 +++++++++++++++++++++------- src/pages/account-statuses.jsx | 22 ++++++++++++- src/pages/following.jsx | 3 +- src/pages/hashtag.jsx | 5 +-- src/pages/list.jsx | 5 +-- src/pages/mentions.jsx | 4 ++- src/pages/public.jsx | 5 +-- src/utils/get-instance-status-url.js | 1 + 8 files changed, 71 insertions(+), 21 deletions(-) diff --git a/src/components/media.jsx b/src/components/media.jsx index e73a8a4e..709291e8 100644 --- a/src/components/media.jsx +++ b/src/components/media.jsx @@ -74,7 +74,7 @@ function Media({ altIndex, onClick = () => {}, }) { - const { + let { blurhash, description, meta, @@ -84,10 +84,17 @@ function Media({ url, type, } = media; + if (/no\-preview\./i.test(previewUrl)) { + previewUrl = null; + } const { original = {}, small, focus } = meta || {}; - const width = showOriginal ? original?.width : small?.width; - const height = showOriginal ? original?.height : small?.height; + const width = showOriginal + ? original?.width + : small?.width || original?.width; + const height = showOriginal + ? original?.height + : small?.height || original?.height; const mediaURL = showOriginal ? url : previewUrl || url; const remoteMediaURL = showOriginal ? remoteUrl @@ -290,7 +297,11 @@ function Media({ }} onError={(e) => { const { src } = e.target; - if (src === mediaURL && mediaURL !== remoteMediaURL) { + if ( + src === mediaURL && + remoteMediaURL && + mediaURL !== remoteMediaURL + ) { e.target.src = remoteMediaURL; } }} @@ -473,14 +484,26 @@ function Media({ /> ) : ( <> - {showInlineDesc + {previewUrl ? ( + {showInlineDesc + ) : ( +