This commit is contained in:
Pascal Temel 2017-09-24 05:54:13 +02:00
parent 4b63ea2d1b
commit b05dac6743
4 changed files with 7 additions and 6 deletions

View File

@ -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)
}

View 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)
}

View 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],

View File

@ -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'
/*