Skip to content

Commit

Permalink
Adjust image sizing (#5302)
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey authored Sep 12, 2024
1 parent d60a8f2 commit 47d99b8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/view/com/util/images/AutoSizedImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ export function useImageAspectRatio({
const [raw, setAspectRatio] = React.useState<number>(
dimensions ? calc(dimensions) : 1,
)
// this basically controls the width of the image
const {isCropped, constrained, max} = React.useMemo(() => {
const a34 = 0.75 // max of 3:4 ratio in feeds
const constrained = Math.max(raw, a34)
const ratio = 1 / 2 // max of 1:2 ratio in feeds
const constrained = Math.max(raw, ratio)
const max = Math.max(raw, 0.25) // max of 1:4 in thread
const isCropped = raw < constrained
return {
Expand Down Expand Up @@ -68,14 +69,14 @@ export function ConstrainedImage({
const t = useTheme()
const {gtMobile} = useBreakpoints()
/**
* Computed as a % value to apply as `paddingTop`
* Computed as a % value to apply as `paddingTop`, this basically controls
* the height of the image.
*/
const outerAspectRatio = React.useMemo<DimensionValue>(() => {
// capped to square or shorter
const ratio =
isNative || !gtMobile
? Math.min(1 / aspectRatio, 1.5)
: Math.min(1 / aspectRatio, 1)
? Math.min(1 / aspectRatio, 16 / 9) // 9:16 bounding box
: Math.min(1 / aspectRatio, 1) // 1:1 bounding box
return `${ratio * 100}%`
}, [aspectRatio, gtMobile])

Expand Down

0 comments on commit 47d99b8

Please sign in to comment.