본문 이미지 파생 파일명 정리

This commit is contained in:
2026-07-02 11:09:14 +09:00
parent 486c8bfe76
commit 7c9b5e9278
14 changed files with 59 additions and 23 deletions

View File

@@ -1,13 +1,13 @@
const postCardThumbnailUrlPattern = /^\/uploads\/posts\/\d{4}\/\d{2}\/thumbs\/[^/?#]+-card\.webp$/i
const pageCoverThumbnailUrlPattern = /^\/uploads\/posts\/\d{4}\/\d{2}\/thumbs\/[^/?#]+-page-cover\.webp$/i
const postBodyThumbnailUrlPattern = /^\/uploads\/posts\/\d{4}\/\d{2}\/thumbs\/[^/?#]+-(?:body(?:-720)?|lightbox)\.webp$/i
const postBodyThumbnailUrlPattern = /^\/uploads\/posts\/\d{4}\/\d{2}\/thumbs\/[^/?#]+-(?:body(?:-(?:720|1600|2560))?|lightbox)\.webp$/i
const postUploadImageUrlPattern = /^\/uploads\/posts\/\d{4}\/\d{2}\/[^/?#]+\.(?:jpe?g|png|webp)$/i
const generatedImageCacheVersion = '20260702-1'
/**
* 게시물 원본 이미지 URL에 대응하는 파생 이미지 URL을 만든다.
* @param {string|null|undefined} imageUrl - 원본 이미지 URL
* @param {'body'|'body-720'|'lightbox'} kind - 파생 이미지 종류
* @param {'body'|'body-720'|'body-1600'|'body-2560'|'lightbox'} kind - 파생 이미지 종류
* @returns {string} 파생 이미지 URL
*/
const getPostDerivativeImageUrl = (imageUrl, kind) => {
@@ -88,7 +88,7 @@ export const withGeneratedImageCacheVersion = (imageUrl, version = generatedImag
* @param {string|null|undefined} imageUrl - 원본 이미지 URL
* @returns {string} 본문 표시용 파생 이미지 URL
*/
export const getPostBodyThumbnailUrl = (imageUrl) => getPostDerivativeImageUrl(imageUrl, 'body')
export const getPostBodyThumbnailUrl = (imageUrl) => getPostDerivativeImageUrl(imageUrl, 'body-1600')
/**
* 게시물 원본 이미지 URL에 대응하는 작은 본문 표시용 이미지 URL을 만든다.
@@ -102,7 +102,21 @@ export const getPostBodyPreviewThumbnailUrl = (imageUrl) => getPostDerivativeIma
* @param {string|null|undefined} imageUrl - 원본 이미지 URL
* @returns {string} 라이트박스용 파생 이미지 URL
*/
export const getPostLightboxThumbnailUrl = (imageUrl) => getPostDerivativeImageUrl(imageUrl, 'lightbox')
export const getPostLightboxThumbnailUrl = (imageUrl) => getPostDerivativeImageUrl(imageUrl, 'body-2560')
/**
* 레거시 본문 표시용 이미지 URL을 만든다.
* @param {string|null|undefined} imageUrl - 원본 이미지 URL
* @returns {string} 레거시 본문 표시용 이미지 URL
*/
export const getLegacyPostBodyThumbnailUrl = (imageUrl) => getPostDerivativeImageUrl(imageUrl, 'body')
/**
* 레거시 라이트박스용 이미지 URL을 만든다.
* @param {string|null|undefined} imageUrl - 원본 이미지 URL
* @returns {string} 레거시 라이트박스용 이미지 URL
*/
export const getLegacyPostLightboxThumbnailUrl = (imageUrl) => getPostDerivativeImageUrl(imageUrl, 'lightbox')
/**
* 페이지 커버 원본 이미지 URL에 대응하는 홈 진열장 썸네일 URL을 만든다.