Rename image size constants and require them as params
POST_IMG_MAX no longer described post images, so rename it to the semantically accurate pair: POST_IMG_MAX_SIZE (4000px/2MB, post images and pasted URLs) and PROFILE_IMAGES_MAX_SIZE (2000px/1MB, avatars, banners, onboarding, link thumbnails). Drop the constant defaults from compressImage, compressIfNeeded, and getResizedDimensions; callers now pass the appropriate max config object directly so the size policy lives at the call site. Web avatar/banner edits now use PROFILE_IMAGES_MAX_SIZE, matching the native profile path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import {sha256} from 'js-sha256'
|
||||
import {CID} from 'multiformats/cid'
|
||||
import * as Hasher from 'multiformats/hashes/hasher'
|
||||
|
||||
import {POST_IMG_MAX_SIZE} from '#/lib/constants'
|
||||
import {isNetworkError} from '#/lib/strings/errors'
|
||||
import {shortenLinks, stripInvalidMentions} from '#/lib/strings/rich-text-manip'
|
||||
import {logger} from '#/logger'
|
||||
@@ -323,7 +324,10 @@ async function resolveMedia(
|
||||
const images: AppBskyEmbedImages.Image[] = await Promise.all(
|
||||
imagesDraft.map(async (image, i) => {
|
||||
logger.debug(`Compressing image #${i}`)
|
||||
const {path, width, height, mime} = await compressImage(image)
|
||||
const {path, width, height, mime} = await compressImage(
|
||||
image,
|
||||
POST_IMG_MAX_SIZE,
|
||||
)
|
||||
logger.debug(`Uploading image #${i}`)
|
||||
const res = await uploadBlob(agent, path, mime)
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user