Add Zotero.Item::numFileAttachments()

This commit is contained in:
Dan Stillman 2024-05-15 05:24:23 -04:00
parent bb146328b8
commit e1f1003318

View file

@ -2461,6 +2461,20 @@ Zotero.Item.prototype.numAttachments = function (includeTrashed) {
}
/**
* Returns the number of file attachments of an item
*
* @return <Integer>
*/
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()