Skip to content

Commit

Permalink
Only inline clipboard attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
senky committed Oct 30, 2019
1 parent 9005fa2 commit 8287713
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions styles/all/template/clipboardimage.js
Expand Up @@ -79,14 +79,23 @@

// no image but some text here - let the browser do its job
});
})(window, jQuery, phpbb, text_name);

// place new image inline
phpbb.plupload.uploader.bind('FileUploaded', function(_, file, response) {
try {
json = JSON.parse(response.response);
if (typeof json.title === 'undefined' && !json.error && file.status === plupload.DONE) {
attachInline(phpbb.plupload.getIndex(json.data[0].attach_id), json.data[0].real_filename);
// place new image inline
phpbb.plupload.uploader.bind('FileUploaded', function(_, file, response) {
// Make sure this image comes from the clipboard.
// Otherwise do not inline the attachment.
var clipboardImg = images.find(function(img) {
return img.name == file.name && img.size == file.origSize;
});
if (!clipboardImg) {
return;
}
} catch (e) {}
});

try {
var json = JSON.parse(response.response);
if (typeof json.title === 'undefined' && !json.error && file.status === plupload.DONE) {
attachInline(phpbb.plupload.getIndex(json.data[0].attach_id), json.data[0].real_filename);
}
} catch (e) {console.log(e)}
});
})(window, jQuery, phpbb, text_name);

0 comments on commit 8287713

Please sign in to comment.