mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-01 00:18:14 +01:00
When setting the cover image prefer images called "cover", otherwise fallback to original behaviour of first in the list.
This commit is contained in:
parent
6e8547f0c8
commit
002fb7a35e
@ -444,8 +444,15 @@ class LibraryItem {
|
|||||||
// Set cover image if not set
|
// Set cover image if not set
|
||||||
const imageFiles = this.libraryFiles.filter(lf => lf.fileType === 'image')
|
const imageFiles = this.libraryFiles.filter(lf => lf.fileType === 'image')
|
||||||
if (imageFiles.length && !this.media.coverPath) {
|
if (imageFiles.length && !this.media.coverPath) {
|
||||||
this.media.coverPath = imageFiles[0].metadata.path
|
//attempt to find a file called cover.<ext> otherwise just fall back to the first image found
|
||||||
Logger.debug('[LibraryItem] Set media cover path', this.media.coverPath)
|
var coverMatch = imageFiles.find(iFile => /\/cover\.[^.\/]*$/.test(iFile.metadata.path))
|
||||||
|
if (coverMatch) {
|
||||||
|
this.media.coverPath = coverMatch.metadata.path
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.media.coverPath = imageFiles[0].metadata.path
|
||||||
|
}
|
||||||
|
Logger.info('[LibraryItem] Set media cover path', this.media.coverPath)
|
||||||
hasUpdated = true
|
hasUpdated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user