mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-31 15:21:33 +00:00
Updates
Experimental changes to allow generating thumbnails only for EITHER images or videos.
This commit is contained in:
parent
421d53d396
commit
66f3b0739d
@ -62,7 +62,8 @@ module.exports = {
|
|||||||
to install a separate binary called graphicsmagick (http://www.graphicsmagick.org)
|
to install a separate binary called graphicsmagick (http://www.graphicsmagick.org)
|
||||||
for images and ffmpeg (https://ffmpeg.org/) for video files
|
for images and ffmpeg (https://ffmpeg.org/) for video files
|
||||||
*/
|
*/
|
||||||
generateThumbnails: false,
|
generateImageThumbnails: true,
|
||||||
|
generateVideoThumbnails: false,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Allows users to download a .zip file of all files in an album.
|
Allows users to download a .zip file of all files in an album.
|
||||||
|
@ -31,13 +31,18 @@ utilsController.authorize = async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
utilsController.generateThumbs = function (file, basedomain) {
|
utilsController.generateThumbs = function (file, basedomain) {
|
||||||
if (config.uploads.generateThumbnails !== true) return
|
|
||||||
const ext = path.extname(file.name).toLowerCase()
|
const ext = path.extname(file.name).toLowerCase()
|
||||||
|
const isVideoExt = utilsController.videoExtensions.includes(ext)
|
||||||
|
const isImageExt = utilsController.imageExtensions.includes(ext)
|
||||||
|
|
||||||
|
if (!isVideoExt && !isImageExt) return
|
||||||
|
if (isVideoExt && config.uploads.generateVideoThumbnails !== true) return
|
||||||
|
if (isImageExt && config.uploads.generateImageThumbnails !== true) return
|
||||||
|
|
||||||
let thumbname = path.join(__dirname, '..', config.uploads.folder, 'thumbs', file.name.slice(0, -ext.length) + '.png')
|
let thumbname = path.join(__dirname, '..', config.uploads.folder, 'thumbs', file.name.slice(0, -ext.length) + '.png')
|
||||||
fs.access(thumbname, err => {
|
fs.access(thumbname, err => {
|
||||||
if (err && err.code === 'ENOENT') {
|
if (err && err.code === 'ENOENT') {
|
||||||
if (utilsController.videoExtensions.includes(ext)) {
|
if (isVideoExt) {
|
||||||
ffmpeg(path.join(__dirname, '..', config.uploads.folder, file.name))
|
ffmpeg(path.join(__dirname, '..', config.uploads.folder, file.name))
|
||||||
.thumbnail({
|
.thumbnail({
|
||||||
timestamps: [0],
|
timestamps: [0],
|
||||||
@ -46,7 +51,7 @@ utilsController.generateThumbs = function (file, basedomain) {
|
|||||||
size: '200x?'
|
size: '200x?'
|
||||||
})
|
})
|
||||||
.on('error', error => console.log('Error - ', error.message))
|
.on('error', error => console.log('Error - ', error.message))
|
||||||
} else {
|
} else if (isImageExt) {
|
||||||
let size = {
|
let size = {
|
||||||
width: 200,
|
width: 200,
|
||||||
height: 200
|
height: 200
|
||||||
|
Loading…
Reference in New Issue
Block a user