Apply per-use-case image size configs (#10690)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,6 @@ import * as MediaLibrary from 'expo-media-library'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
|
||||
import {POST_IMG_MAX} from '#/lib/constants'
|
||||
import {useCameraPermission} from '#/lib/hooks/usePermissions'
|
||||
import {openCamera} from '#/lib/media/picker'
|
||||
import {logger} from '#/logger'
|
||||
@@ -35,7 +34,7 @@ export function OpenCameraBtn({disabled, onAdd}: Props) {
|
||||
}
|
||||
|
||||
const img = await openCamera({
|
||||
aspect: [POST_IMG_MAX.width, POST_IMG_MAX.height],
|
||||
aspect: [1, 1],
|
||||
})
|
||||
|
||||
// If we don't have permissions it's fine, we just wont save it. The post itself will still have access to
|
||||
|
||||
@@ -16,7 +16,7 @@ import {type PasteEventPayload, TextInputWrapper} from 'expo-paste-input'
|
||||
import {AppBskyRichtextFacet, RichText} from '@atproto/api'
|
||||
import {useLingui} from '@lingui/react/macro'
|
||||
|
||||
import {POST_IMG_MAX} from '#/lib/constants'
|
||||
import {IMAGE_SIZE_CONFIG_POSTS} from '#/lib/constants'
|
||||
import {downloadAndResize} from '#/lib/media/manip'
|
||||
import {isUriImage} from '#/lib/media/util'
|
||||
import {getMentionAt, insertMentionAt} from '#/lib/strings/mention-manip'
|
||||
@@ -93,10 +93,7 @@ export function TextInput({
|
||||
if (isUriImage(feature.uri)) {
|
||||
const res = await downloadAndResize({
|
||||
uri: feature.uri,
|
||||
width: POST_IMG_MAX.width,
|
||||
height: POST_IMG_MAX.height,
|
||||
mode: 'contain',
|
||||
maxSize: POST_IMG_MAX.size,
|
||||
...IMAGE_SIZE_CONFIG_POSTS,
|
||||
timeout: 15e3,
|
||||
})
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import {useLingui} from '@lingui/react'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
import {useQueryClient} from '@tanstack/react-query'
|
||||
|
||||
import {IMAGE_SIZE_CONFIG_2K_1MB} from '#/lib/constants'
|
||||
import {useHaptics} from '#/lib/haptics'
|
||||
import {
|
||||
useCameraPermission,
|
||||
@@ -395,6 +396,7 @@ let EditableUserAvatar = ({
|
||||
await openCamera({
|
||||
aspect: [1, 1],
|
||||
}),
|
||||
IMAGE_SIZE_CONFIG_2K_1MB,
|
||||
),
|
||||
)
|
||||
}, [onSelectNewAvatar, requestCameraAccessIfNeeded])
|
||||
@@ -423,6 +425,7 @@ let EditableUserAvatar = ({
|
||||
shape: circular ? 'circle' : 'rectangle',
|
||||
aspectRatio: 1,
|
||||
}),
|
||||
IMAGE_SIZE_CONFIG_2K_1MB,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
@@ -449,7 +452,7 @@ let EditableUserAvatar = ({
|
||||
|
||||
const onChangeEditImage = useCallback(
|
||||
async (image: ComposerImage) => {
|
||||
const compressed = await compressImage(image)
|
||||
const compressed = await compressImage(image, IMAGE_SIZE_CONFIG_2K_1MB)
|
||||
onSelectNewAvatar(compressed)
|
||||
},
|
||||
[onSelectNewAvatar],
|
||||
|
||||
@@ -6,6 +6,7 @@ import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
|
||||
import {IMAGE_SIZE_CONFIG_2K_1MB} from '#/lib/constants'
|
||||
import {
|
||||
useCameraPermission,
|
||||
usePhotoLibraryPermission,
|
||||
@@ -62,6 +63,7 @@ export function UserBanner({
|
||||
await openCamera({
|
||||
aspect: [3, 1],
|
||||
}),
|
||||
IMAGE_SIZE_CONFIG_2K_1MB,
|
||||
),
|
||||
)
|
||||
}, [onSelectNewBanner, requestCameraAccessIfNeeded])
|
||||
@@ -83,6 +85,7 @@ export function UserBanner({
|
||||
imageUri: items[0].path,
|
||||
aspectRatio: 3 / 1,
|
||||
}),
|
||||
IMAGE_SIZE_CONFIG_2K_1MB,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
@@ -108,7 +111,7 @@ export function UserBanner({
|
||||
|
||||
const onChangeEditImage = useCallback(
|
||||
async (image: ComposerImage) => {
|
||||
const compressed = await compressImage(image)
|
||||
const compressed = await compressImage(image, IMAGE_SIZE_CONFIG_2K_1MB)
|
||||
onSelectNewBanner?.(compressed)
|
||||
},
|
||||
[onSelectNewBanner],
|
||||
|
||||
Reference in New Issue
Block a user