diff --git a/app/soapbox/components/media-gallery.tsx b/app/soapbox/components/media-gallery.tsx index 42b961dc1..1a6754210 100644 --- a/app/soapbox/components/media-gallery.tsx +++ b/app/soapbox/components/media-gallery.tsx @@ -160,16 +160,21 @@ const Item: React.FC = ({ ); } else if (attachment.type === 'image') { - const letterboxed = shouldLetterbox(attachment); + const letterboxed = total === 1 && shouldLetterbox(attachment); thumbnail = ( - + ); } else if (attachment.type === 'gifv') { diff --git a/app/soapbox/components/still-image.tsx b/app/soapbox/components/still-image.tsx index 24e212ce5..38e72a6b6 100644 --- a/app/soapbox/components/still-image.tsx +++ b/app/soapbox/components/still-image.tsx @@ -12,10 +12,12 @@ interface IStillImage { src: string, /** Extra CSS styles on the outer
element. */ style?: React.CSSProperties, + /** Whether to display the image contained vs filled in its container. */ + letterboxed?: boolean, } /** Renders images on a canvas, only playing GIFs if autoPlayGif is enabled. */ -const StillImage: React.FC = ({ alt, className, src, style }) => { +const StillImage: React.FC = ({ alt, className, src, style, letterboxed = false }) => { const settings = useSettings(); const autoPlayGif = settings.get('autoPlayGif'); @@ -34,10 +36,38 @@ const StillImage: React.FC = ({ alt, className, src, style }) => { } }; + /** ClassNames shared between the `` and `` elements. */ + const baseClassName = classNames('w-full h-full block', { + 'object-contain': letterboxed, + 'object-cover': !letterboxed, + }); + return ( -
- {alt} - {hoverToPlay && } +
+
+ {alt} + + {hoverToPlay && ( + + )} +
); }; diff --git a/app/soapbox/features/account-gallery/components/media-item.tsx b/app/soapbox/features/account-gallery/components/media-item.tsx index a2a171bfc..4242094b5 100644 --- a/app/soapbox/features/account-gallery/components/media-item.tsx +++ b/app/soapbox/features/account-gallery/components/media-item.tsx @@ -74,6 +74,7 @@ const MediaItem: React.FC = ({ attachment, displayWidth, onOpenMedia src={attachment.preview_url} alt={attachment.description} style={{ objectPosition: `${x}% ${y}%` }} + className='w-full h-full rounded-lg overflow-hidden' /> ); } else if (['gifv', 'video'].indexOf(attachment.type) !== -1) { diff --git a/app/soapbox/features/account/components/header.tsx b/app/soapbox/features/account/components/header.tsx index 4aa4d3b05..ef41e9ccf 100644 --- a/app/soapbox/features/account/components/header.tsx +++ b/app/soapbox/features/account/components/header.tsx @@ -577,7 +577,7 @@ const Header: React.FC = ({ account }) => {