본문 이미지 최적화 및 백필 보정

This commit is contained in:
2026-07-01 17:35:19 +09:00
parent 943794ae34
commit 78ab394f7a
18 changed files with 437 additions and 20 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\.webp$/i
const postBodyThumbnailUrlPattern = /^\/uploads\/posts\/\d{4}\/\d{2}\/thumbs\/[^/?#]+-body(?:-720)?\.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'} kind - 파생 이미지 종류
* @param {'body'|'body-720'} kind - 파생 이미지 종류
* @returns {string} 파생 이미지 URL
*/
const getPostDerivativeImageUrl = (imageUrl, kind) => {
@@ -48,3 +48,10 @@ export const isPostBodyThumbnailUrl = (imageUrl) => Boolean(
* @returns {string} 본문 표시용 파생 이미지 URL
*/
export const getPostBodyThumbnailUrl = (imageUrl) => getPostDerivativeImageUrl(imageUrl, 'body')
/**
* 게시물 원본 이미지 URL에 대응하는 작은 본문 표시용 이미지 URL을 만든다.
* @param {string|null|undefined} imageUrl - 원본 이미지 URL
* @returns {string} 작은 본문 표시용 파생 이미지 URL
*/
export const getPostBodyPreviewThumbnailUrl = (imageUrl) => getPostDerivativeImageUrl(imageUrl, 'body-720')