/
alt3rmann
/
LibreChat
Обзор
Документация
Войти
/
alt3rmann
/
LibreChat
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
client/src/utils/scaleImage.ts
21 строка
637 B
Marco Beretta
🖼️ feat: Tool Call and Loading UI Refresh, Image Resize Config (#7086)
20 май 2025, 02:23
Не верифицирован
20 май 2025, 02:23
c79ee32
Код
Авторство
О чём код?
export default function scaleImage({ originalWidth, originalHeight, containerRef, }: { originalWidth?: number; originalHeight?: number; containerRef: React.RefObject<HTMLDivElement>; }) { const containerWidth = containerRef.current?.offsetWidth ?? 0; if (containerWidth === 0 || originalWidth == null || originalHeight == null) { return { width: 'auto', height: 'auto' }; } const aspectRatio = originalWidth / originalHeight; const scaledWidth = Math.min(containerWidth, originalWidth); const scaledHeight = scaledWidth / aspectRatio; return { width: `${scaledWidth}px`, height: `${scaledHeight}px` }; }