mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 07:56:23 +00:00
cleanup
This commit is contained in:
parent
4b63ea2d1b
commit
b05dac6743
@ -155,7 +155,7 @@ albumsController.get = function(req, res, next) {
|
||||
file.file = basedomain + '/' + file.name
|
||||
|
||||
let ext = path.extname(file.name).toLowerCase()
|
||||
if (utils.extensions.includes(ext)) {
|
||||
if (utils.imageExtensions.includes(ext) || utils.videoExtensions.includes(ext)) {
|
||||
file.thumb = basedomain + '/thumbs/' + file.name.slice(0, -ext.length) + '.png'
|
||||
utils.generateThumbs(file)
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ uploadsController.processFilesForDisplay = function(req, res, files, existingFil
|
||||
|
||||
for (let file of files) {
|
||||
let ext = path.extname(file.name).toLowerCase()
|
||||
if (utils.extensions.includes(ext)) {
|
||||
if (utils.imageExtensions.includes(ext) || utils.videoExtensions.includes(ext)) {
|
||||
file.thumb = basedomain + '/thumbs/' + file.name.slice(0, -ext.length) + '.png'
|
||||
utils.generateThumbs(file)
|
||||
}
|
||||
@ -300,7 +300,7 @@ uploadsController.list = function(req, res) {
|
||||
userids.push(file.userid)
|
||||
|
||||
let ext = path.extname(file.name).toLowerCase()
|
||||
if (utils.extensions.includes(ext)) {
|
||||
if (utils.imageExtensions.includes(ext) || utils.videoExtensions.includes(ext)) {
|
||||
file.thumb = basedomain + '/thumbs/' + file.name.slice(0, -ext.length) + '.png'
|
||||
utils.generateThumbs(file)
|
||||
}
|
||||
|
@ -5,7 +5,8 @@ const gm = require('gm')
|
||||
const ffmpeg = require('fluent-ffmpeg')
|
||||
|
||||
const utilsController = {}
|
||||
utilsController.extensions = ['.jpg', '.jpeg', '.bmp', '.gif', '.png', '.webm', '.mp4', '.wmv', '.avi', '.mov']
|
||||
utilsController.imageExtensions = ['.jpg', '.jpeg', '.bmp', '.gif', '.png']
|
||||
utilsController.videoExtensions = ['.webm', '.mp4', '.wmv', '.avi', '.mov']
|
||||
|
||||
utilsController.getPrettyDate = function(date) {
|
||||
return date.getFullYear() + '-'
|
||||
@ -26,7 +27,7 @@ utilsController.generateThumbs = function(file, basedomain) {
|
||||
let thumbname = path.join(__dirname, '..', config.uploads.folder, 'thumbs', file.name.slice(0, -ext.length) + '.png')
|
||||
fs.access(thumbname, (err) => {
|
||||
if (err && err.code === 'ENOENT') {
|
||||
if (ext === '.webm' || ext === '.mp4' || ext === '.wmv' || ext === '.avi' || ext === '.mov') {
|
||||
if (utilsController.videoExtensions.includes(ext)) {
|
||||
ffmpeg(path.join(__dirname, '..', config.uploads.folder, file.name))
|
||||
.thumbnail({
|
||||
timestamps: [0],
|
||||
|
@ -28,7 +28,7 @@ routes.get('/a/:identifier', (req, res, next) => {
|
||||
file.file = basedomain + '/' + file.name
|
||||
|
||||
let ext = path.extname(file.name).toLowerCase()
|
||||
if (utils.extensions.includes(ext)) {
|
||||
if (utils.imageExtensions.includes(ext) || utils.videoExtensions.includes(ext)) {
|
||||
file.thumb = basedomain + '/thumbs/' + file.name.slice(0, -ext.length) + '.png'
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user