mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-04-07 01:15:44 +02:00
Update:Author cover image API endpoint to get raw cover image #1291
This commit is contained in:
parent
8f49aae979
commit
e1397a6dda
@ -1,8 +1,11 @@
|
|||||||
|
|
||||||
|
const fs = require('../libs/fsExtra')
|
||||||
|
const { createNewSortInstance } = require('../libs/fastSort')
|
||||||
|
|
||||||
const Logger = require('../Logger')
|
const Logger = require('../Logger')
|
||||||
const SocketAuthority = require('../SocketAuthority')
|
const SocketAuthority = require('../SocketAuthority')
|
||||||
|
|
||||||
const { reqSupportsWebp } = require('../utils/index')
|
const { reqSupportsWebp } = require('../utils/index')
|
||||||
const { createNewSortInstance } = require('../libs/fastSort')
|
|
||||||
|
|
||||||
const naturalSort = createNewSortInstance({
|
const naturalSort = createNewSortInstance({
|
||||||
comparer: new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }).compare
|
comparer: new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }).compare
|
||||||
@ -206,7 +209,15 @@ class AuthorController {
|
|||||||
|
|
||||||
// GET api/authors/:id/image
|
// GET api/authors/:id/image
|
||||||
async getImage(req, res) {
|
async getImage(req, res) {
|
||||||
let { query: { width, height, format }, author } = req
|
const { query: { width, height, format, raw }, author } = req
|
||||||
|
|
||||||
|
if (raw) { // any value
|
||||||
|
if (!author.imagePath || !await fs.pathExists(author.imagePath)) {
|
||||||
|
return res.sendStatus(404)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.sendFile(author.imagePath)
|
||||||
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
format: format || (reqSupportsWebp(req) ? 'webp' : 'jpeg'),
|
format: format || (reqSupportsWebp(req) ? 'webp' : 'jpeg'),
|
||||||
|
Loading…
Reference in New Issue
Block a user