Merge branch 'feature/456' of https://github.com/tainacan/tainacan into feature/456

This commit is contained in:
mateuswetah 2020-12-18 11:36:28 -03:00
commit 502a9fb0ee
1 changed files with 10 additions and 1 deletions

View File

@ -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
*