라이트박스 이미지 파생 파일 적용

This commit is contained in:
2026-07-01 17:42:12 +09:00
parent 78ab394f7a
commit 129b68b939
13 changed files with 122 additions and 19 deletions

View File

@@ -1,11 +1,11 @@
const postCardThumbnailUrlPattern = /^\/uploads\/posts\/\d{4}\/\d{2}\/thumbs\/[^/?#]+-card\.webp$/i
const postBodyThumbnailUrlPattern = /^\/uploads\/posts\/\d{4}\/\d{2}\/thumbs\/[^/?#]+-body(?:-720)?\.webp$/i
const postBodyThumbnailUrlPattern = /^\/uploads\/posts\/\d{4}\/\d{2}\/thumbs\/[^/?#]+-(?:body(?:-720)?|lightbox)\.webp$/i
const postUploadImageUrlPattern = /^\/uploads\/posts\/\d{4}\/\d{2}\/[^/?#]+\.(?:jpe?g|png|webp)$/i
/**
* 게시물 원본 이미지 URL에 대응하는 파생 이미지 URL을 만든다.
* @param {string|null|undefined} imageUrl - 원본 이미지 URL
* @param {'body'|'body-720'} kind - 파생 이미지 종류
* @param {'body'|'body-720'|'lightbox'} kind - 파생 이미지 종류
* @returns {string} 파생 이미지 URL
*/
const getPostDerivativeImageUrl = (imageUrl, kind) => {
@@ -55,3 +55,10 @@ export const getPostBodyThumbnailUrl = (imageUrl) => getPostDerivativeImageUrl(i
* @returns {string} 작은 본문 표시용 파생 이미지 URL
*/
export const getPostBodyPreviewThumbnailUrl = (imageUrl) => getPostDerivativeImageUrl(imageUrl, 'body-720')
/**
* 게시물 원본 이미지 URL에 대응하는 라이트박스용 이미지 URL을 만든다.
* @param {string|null|undefined} imageUrl - 원본 이미지 URL
* @returns {string} 라이트박스용 파생 이미지 URL
*/
export const getPostLightboxThumbnailUrl = (imageUrl) => getPostDerivativeImageUrl(imageUrl, 'lightbox')