Streamline next image types

This commit is contained in:
Sam Becker 2023-09-25 20:47:44 -05:00
parent 87122d69b3
commit 54168dfe80
2 changed files with 7 additions and 6 deletions

View File

@ -1,5 +1,5 @@
import { Photo } from '..';
import { NextImageWidth } from '@/utility/image';
import { NextCustomSize } from '@/utility/image';
import { formatModelShort } from '@/utility/exif';
import { AiFillApple } from 'react-icons/ai';
import ImageCaption from './components/ImageCaption';
@ -13,7 +13,7 @@ export default function PhotoImageResponse({
fontFamily,
}: {
photo: Photo
width: NextImageWidth
width: NextCustomSize
height: number
fontFamily: string
}) {

View File

@ -1,15 +1,16 @@
import { BASE_URL } from '@/site/config';
// Must be explicity defined next.config.js `imageSizes`
// or `deviceSizes` ([640, 750, 828, 1080, 1200, 1920, 2048, 3840])
export type NextImageWidth =
// Explicity defined next.config.js `imageSizes`
export type NextCustomSize =
200 | 400 | 1050;
export type NextImageDeviceSize =
640 | 750 | 828 | 1080 | 1200 | 1920 | 2048 | 3840;
export type NextImageWidth = NextCustomSize | NextImageDeviceSize;
export const getNextImageUrlForRequest = (
imageUrl: string,
width: NextImageWidth | NextImageDeviceSize,
width: NextImageWidth,
quality = 75,
) => {
const url = new URL(`${BASE_URL}/_next/image`);