diff --git a/server/utils/parsers/parseEpubMetadata.js b/server/utils/parsers/parseEpubMetadata.js index 25d8821d..7bffc601 100644 --- a/server/utils/parsers/parseEpubMetadata.js +++ b/server/utils/parsers/parseEpubMetadata.js @@ -107,7 +107,8 @@ async function parse(ebookFile) { // Attempt to find filepath to cover image: // Metadata may include where content is the id of the cover image in the manifest - // Otherwise the first image in the manifest is used as the cover image + // Otherwise find image in the manifest with cover-image property set + // As a fallback the first image in the manifest is used as the cover image let packageMetadata = packageJson.package?.metadata if (Array.isArray(packageMetadata)) { packageMetadata = packageMetadata[0] @@ -118,6 +119,9 @@ async function parse(ebookFile) { if (metaCoverId) { manifestFirstImage = packageJson.package?.manifest?.[0]?.item?.find((item) => item.$?.id === metaCoverId) } + if (!manifestFirstImage) { + manifestFirstImage = packageJson.package?.manifest?.[0]?.item?.find((item) => item.$?.['properties']?.split(' ')?.includes('cover-image')) + } if (!manifestFirstImage) { manifestFirstImage = packageJson.package?.manifest?.[0]?.item?.find((item) => item.$?.['media-type']?.startsWith('image/')) }