diff --git a/lib/modules/apostrophe-attachments/lib/api.js b/lib/modules/apostrophe-attachments/lib/api.js index 160ec01a45..14e4ebb23e 100644 --- a/lib/modules/apostrophe-attachments/lib/api.js +++ b/lib/modules/apostrophe-attachments/lib/api.js @@ -120,21 +120,29 @@ module.exports = function(self, options) { } if (info.extension === 'jpg') { - const data = exif.parseSync(file.path); - console.log(data); - info.description = data.ImageDescription ? data.ImageDescription.trim() : null; - - if (data.Make && data.Model) { - info.camera = data.Make.trim() + ' ' + data.Model.trim(); - } else if (data.Model) { - info.camera = data.Model.trim(); - } - - info.captureDate = data.DateTime ? data.DateTime : null; - info.credit = data.Copyright ? data.Copyright.trim() : null; + exif.parse(file.path, (err, exifData) => { + if (err) { + console.log(err); + } else { + + const data = exifData; + info.description = data.ImageDescription ? data.ImageDescription.trim() : null; + + if (data.Make && data.Model) { + info.camera = data.Make.trim() + ' ' + data.Model.trim(); + } else if (data.Model) { + info.camera = data.Model.trim(); + } + + info.captureDate = data.DateTime ? data.DateTime : null; + info.credit = data.Copyright ? data.Copyright.trim() : null; + } + + return callback(null); + }); + } else { + return callback(null); } - - return callback(null); }); } else { // For non-image files we have to trust the file extension