Update:Get item cover API endpoint to allow for returning the raw cover image

This commit is contained in:
advplyr
2022-12-04 16:23:15 -06:00
parent 3ea3e55d17
commit 67db41a525
2 changed files with 12 additions and 3 deletions

View File

@ -1,3 +1,4 @@
const fs = require('../libs/fsExtra')
const Logger = require('../Logger')
const SocketAuthority = require('../SocketAuthority')
@ -178,7 +179,15 @@ class LibraryItemController {
// GET api/items/:id/cover
async getCover(req, res) {
let { query: { width, height, format }, libraryItem } = req
const { query: { width, height, format, raw }, libraryItem } = req
if (raw) { // any value
if (!libraryItem.media.coverPath || !await fs.pathExists(libraryItem.media.coverPath)) {
return res.sendStatus(404)
}
return res.sendFile(libraryItem.media.coverPath)
}
const options = {
format: format || (reqSupportsWebp(req) ? 'webp' : 'jpeg'),