mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 16:05:49 +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:
18
src/image.js
18
src/image.js
@@ -7,18 +7,18 @@ var fs = require('fs'),
|
||||
|
||||
var image = {};
|
||||
|
||||
image.resizeImage = function(path, extension, width, height, callback) {
|
||||
image.resizeImage = function(data, callback) {
|
||||
if (plugins.hasListeners('filter:image.resize')) {
|
||||
plugins.fireHook('filter:image.resize', {
|
||||
path: path,
|
||||
extension: extension,
|
||||
width: width,
|
||||
height: height
|
||||
path: data.path,
|
||||
extension: data.extension,
|
||||
width: data.width,
|
||||
height: data.height
|
||||
}, function(err, data) {
|
||||
callback(err);
|
||||
});
|
||||
} else {
|
||||
new Jimp(path, function(err, image) {
|
||||
new Jimp(data.path, function(err, image) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ image.resizeImage = function(path, extension, width, height, callback) {
|
||||
var w = image.bitmap.width,
|
||||
h = image.bitmap.height,
|
||||
origRatio = w/h,
|
||||
desiredRatio = width/height,
|
||||
desiredRatio = data.width/data.height,
|
||||
x = 0,
|
||||
y = 0,
|
||||
crop;
|
||||
@@ -47,10 +47,10 @@ image.resizeImage = function(path, extension, width, height, callback) {
|
||||
async.waterfall([
|
||||
crop,
|
||||
function(image, next) {
|
||||
image.resize(width, height, next);
|
||||
image.resize(data.width, data.height, next);
|
||||
},
|
||||
function(image, next) {
|
||||
image.write(path, next);
|
||||
image.write(data.target || data.path, next);
|
||||
}
|
||||
], function(err) {
|
||||
callback(err);
|
||||
|
||||
Reference in New Issue
Block a user