mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-23 01:09:26 +02:00
Update photo url input to photo path/url to be consistent with item covers
This commit is contained in:
parent
f79b4d44b9
commit
35ab4cb2fe
3 changed files with 22 additions and 23 deletions
|
@ -63,9 +63,20 @@ class AuthorController {
|
|||
// If updating or removing cover image then clear cache
|
||||
if (payload.imagePath !== undefined && req.author.imagePath && payload.imagePath !== req.author.imagePath) {
|
||||
this.cacheManager.purgeImageCache(req.author.id)
|
||||
|
||||
if (!payload.imagePath) { // If removing image then remove file
|
||||
var currentImagePath = req.author.imagePath
|
||||
await this.coverManager.removeFile(currentImagePath)
|
||||
} else if (payload.imagePath.startsWith('http')) { // Check if image path is a url
|
||||
var imageData = await this.authorFinder.saveAuthorImage(req.author.id, payload.imagePath)
|
||||
if (imageData) {
|
||||
req.author.imagePath = imageData.path
|
||||
req.author.relImagePath = imageData.relPath
|
||||
hasUpdated = hasUpdated || true;
|
||||
} else {
|
||||
req.author.imagePath = null
|
||||
req.author.relImagePath = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,16 +84,6 @@ class AuthorController {
|
|||
|
||||
var hasUpdated = req.author.update(payload)
|
||||
|
||||
// Fetch author image from remote URL if no current image exists
|
||||
if (payload.imageUrl !== undefined && !req.author.imagePath) {
|
||||
var imageData = await this.authorFinder.saveAuthorImage(req.author.id, payload.imageUrl)
|
||||
if (imageData) {
|
||||
req.author.imagePath = imageData.path
|
||||
req.author.relImagePath = imageData.relPath
|
||||
hasUpdated = hasUpdated || true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasUpdated) {
|
||||
if (authorNameUpdate) { // Update author name on all books
|
||||
var itemsWithAuthor = this.db.libraryItems.filter(li => li.mediaType === 'book' && li.media.metadata.hasAuthor(req.author.id))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue