diff --git a/src/classes/entities/class-tainacan-item.php b/src/classes/entities/class-tainacan-item.php index 9a98ed622..576a8b7f1 100644 --- a/src/classes/entities/class-tainacan-item.php +++ b/src/classes/entities/class-tainacan-item.php @@ -57,7 +57,7 @@ class Item extends Entity { $array_item['url'] = get_permalink( $this->get_id() ); $array_item['creation_date'] = $this->get_date_i18n( explode( ' ', $array_item['creation_date'] )[0] ); $array_item['modification_date'] = $this->get_date_i18n( explode( ' ', $array_item['modification_date'] )[0] ); - + $array_item['document_mimetype'] = $this->get_document_mimetype(); return apply_filters('tainacan-item-to-array', $array_item, $this); } @@ -275,6 +275,15 @@ class Item extends Entity { return $this->get_mapped_property( 'document_type' ); } + /** + * Return the document mimetype + * + * @return string + */ + function get_document_mimetype() { + return $this->get_document_type() == 'attachment' ? get_post_mime_type($this->get_document()) : $this->get_document_type(); + } + /** * Return the item document *