added a hook to post image upload for starters, more coming

v1.18.x
Baris Soner Usakli 11 years ago
parent c78942b7a4
commit 0f2e7fa8bd

@ -396,25 +396,30 @@ var db = require('./database'),
Posts.uploadPostImage = function(image, callback) {
if(meta.config.imgurClientID) {
if(!image || !image.data) {
return callback(new Error('invalid image'));
}
if(plugins.hasListeners('filter:post.upload')) {
plugins.fireHook('filter:post.upload', image, callback);
} else {
require('./imgur').upload(meta.config.imgurClientID, image.data, 'base64', function(err, data) {
if(err) {
return callback(err);
if(meta.config.imgurClientID) {
if(!image || !image.data) {
return callback(new Error('invalid image'));
}
callback(null, {
url: data.link,
name: image.name
require('./imgur').upload(meta.config.imgurClientID, image.data, 'base64', function(err, data) {
if(err) {
return callback(err);
}
callback(null, {
url: data.link,
name: image.name
});
});
});
} else if (meta.config.allowFileUploads) {
Posts.uploadPostFile(image, callback);
} else {
callback(new Error('Uploads are disabled!'));
} else if (meta.config.allowFileUploads) {
Posts.uploadPostFile(image, callback);
} else {
callback(new Error('Uploads are disabled!'));
}
}
}

Loading…
Cancel
Save