diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index a3f3d94859..ff4facbb1b 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -2461,6 +2461,20 @@ Zotero.Item.prototype.numAttachments = function (includeTrashed) { } +/** + * Returns the number of file attachments of an item + * + * @return + */ +Zotero.Item.prototype.numFileAttachments = function () { + this._requireData('childItems'); + return this.getAttachments() + .map(itemID => Zotero.Items.get(itemID)) + .filter(item => item.isFileAttachment()) + .length; +}; + + Zotero.Item.prototype.numNonHTMLFileAttachments = function () { this._requireData('childItems'); return this.getAttachments()