mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Merge pull request #4106 from Roukanken42/fix/loading-epub-covers
Fix: Load epub covers via cover-image property
This commit is contained in:
		
						commit
						e504bb09eb
					
				@ -107,7 +107,8 @@ async function parse(ebookFile) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // Attempt to find filepath to cover image:
 | 
					  // Attempt to find filepath to cover image:
 | 
				
			||||||
  // Metadata may include <meta name="cover" content="id"/> where content is the id of the cover image in the manifest
 | 
					  // Metadata may include <meta name="cover" content="id"/> 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
 | 
					  let packageMetadata = packageJson.package?.metadata
 | 
				
			||||||
  if (Array.isArray(packageMetadata)) {
 | 
					  if (Array.isArray(packageMetadata)) {
 | 
				
			||||||
    packageMetadata = packageMetadata[0]
 | 
					    packageMetadata = packageMetadata[0]
 | 
				
			||||||
@ -118,6 +119,9 @@ async function parse(ebookFile) {
 | 
				
			|||||||
  if (metaCoverId) {
 | 
					  if (metaCoverId) {
 | 
				
			||||||
    manifestFirstImage = packageJson.package?.manifest?.[0]?.item?.find((item) => item.$?.id === 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) {
 | 
					  if (!manifestFirstImage) {
 | 
				
			||||||
    manifestFirstImage = packageJson.package?.manifest?.[0]?.item?.find((item) => item.$?.['media-type']?.startsWith('image/'))
 | 
					    manifestFirstImage = packageJson.package?.manifest?.[0]?.item?.find((item) => item.$?.['media-type']?.startsWith('image/'))
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user