미디어 본문 파생 이미지 분류 수정
This commit is contained in:
@@ -4,7 +4,9 @@ import { createError } from 'h3'
|
||||
import { getSiteSettings, listAdminPosts, listAdminTags, listPages } from '../repositories/content-repository'
|
||||
import { getPostgresClient } from '../repositories/postgres-client'
|
||||
import {
|
||||
getPostBodyPreviewThumbnailUrl,
|
||||
getPostBodyThumbnailUrl,
|
||||
getPostLightboxThumbnailUrl,
|
||||
getPostThumbnailUrl,
|
||||
isPostBodyThumbnailUrl,
|
||||
isPostCardThumbnailUrl,
|
||||
@@ -587,11 +589,31 @@ const buildPostThumbnailOwnerMap = (items) => buildPostDerivativeOwnerMap(
|
||||
* @param {Array<Object>} items - 미디어 항목 목록
|
||||
* @returns {Map<string, string>} 본문 표시용 이미지 URL별 원본 URL
|
||||
*/
|
||||
const buildPostBodyThumbnailOwnerMap = (items) => buildPostDerivativeOwnerMap(
|
||||
items,
|
||||
getPostBodyThumbnailUrl,
|
||||
isPostBodyThumbnailUrl
|
||||
)
|
||||
const buildPostBodyThumbnailOwnerMap = (items) => {
|
||||
const itemUrlSet = new Set(items.map((item) => item.url))
|
||||
const ownerByDerivativeUrl = new Map()
|
||||
const bodyDerivativeUrlGetters = [
|
||||
getPostBodyThumbnailUrl,
|
||||
getPostBodyPreviewThumbnailUrl,
|
||||
getPostLightboxThumbnailUrl
|
||||
]
|
||||
|
||||
for (const item of items) {
|
||||
if (isPostBodyThumbnailUrl(item.url) || isPostCardThumbnailUrl(item.url) || !isPostThumbnailSource('', item.name)) {
|
||||
continue
|
||||
}
|
||||
|
||||
for (const getDerivativeUrl of bodyDerivativeUrlGetters) {
|
||||
const derivativeUrl = getDerivativeUrl(item.url)
|
||||
|
||||
if (derivativeUrl && itemUrlSet.has(derivativeUrl)) {
|
||||
ownerByDerivativeUrl.set(derivativeUrl, item.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ownerByDerivativeUrl
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시물 카드 썸네일의 간접 사용처를 조회한다.
|
||||
|
||||
Reference in New Issue
Block a user