mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-05 12:01:17 +01:00
Add new ACP option to upload Touch Icon, #3668
Also added a number of fixes for mobile enhancements, such as serving a manifest.json file for Android devices, and serving proper link tags for all uploaded touch icons. This commit also creates a new template helper for link tags.
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
async = require('async'),
|
||||
nconf = require('nconf'),
|
||||
winston = require('winston'),
|
||||
file = require('../../file'),
|
||||
image = require('../../image'),
|
||||
plugins = require('../../plugins');
|
||||
|
||||
|
||||
@@ -52,6 +54,41 @@ uploadsController.uploadFavicon = function(req, res, next) {
|
||||
}
|
||||
};
|
||||
|
||||
uploadsController.uploadTouchIcon = function(req, res, next) {
|
||||
var uploadedFile = req.files.files[0],
|
||||
allowedTypes = ['image/png'],
|
||||
sizes = [36, 48, 72, 96, 144, 192];
|
||||
|
||||
if (validateUpload(req, res, next, uploadedFile, allowedTypes)) {
|
||||
file.saveFileToLocal('touchicon-orig.png', 'system', uploadedFile.path, function(err, imageObj) {
|
||||
// Resize the image into squares for use as touch icons at various DPIs
|
||||
async.each(sizes, function(size, next) {
|
||||
async.series([
|
||||
async.apply(file.saveFileToLocal, 'touchicon-' + size + '.png', 'system', uploadedFile.path),
|
||||
async.apply(image.resizeImage, {
|
||||
path: path.join(nconf.get('base_dir'), nconf.get('upload_path'), 'system', 'touchicon-' + size + '.png'),
|
||||
extension: 'png',
|
||||
width: size,
|
||||
height: size
|
||||
})
|
||||
], next);
|
||||
}, function(err) {
|
||||
fs.unlink(uploadedFile.path, function(err) {
|
||||
if (err) {
|
||||
winston.error(err);
|
||||
}
|
||||
});
|
||||
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
res.json([{name: uploadedFile.name, url: imageObj.url}]);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
uploadsController.uploadLogo = function(req, res, next) {
|
||||
upload('site-logo', req, res, next);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user