feat: add document mimetype #456

This commit is contained in:
vnmedeiros 2020-12-18 10:35:59 -03:00
parent ea9748cd3e
commit 1507b29cf1
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);
}
@ -274,6 +274,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
*