fix: add property thumbnail_alt on item API #177

This commit is contained in:
vnmedeiros 2020-10-09 16:57:11 -03:00
parent d12e2622d4
commit 35f0c1e655
1 changed files with 3 additions and 0 deletions

View File

@ -234,6 +234,7 @@ class REST_Items_Controller extends REST_Controller {
if ( $request->get_method() != 'GET') { if ( $request->get_method() != 'GET') {
$item_arr['thumbnail'] = $item->get_thumbnail(); $item_arr['thumbnail'] = $item->get_thumbnail();
$item_arr['thumbnail_alt'] = get_post_meta( $item->get__thumbnail_id(), '_wp_attachment_image_alt', true );
} }
} else { } else {
@ -272,6 +273,8 @@ class REST_Items_Controller extends REST_Controller {
$item_arr['current_user_can_edit'] = $item->can_edit(); $item_arr['current_user_can_edit'] = $item->can_edit();
$item_arr['current_user_can_delete'] = $item->can_delete(); $item_arr['current_user_can_delete'] = $item->can_delete();
} }
if( isset($item_arr['thumbnail']) )
$item_arr['thumbnail_alt'] = get_post_meta( $item->get__thumbnail_id(), '_wp_attachment_image_alt', true );
$item_arr['url'] = get_permalink( $item_arr['id'] ); $item_arr['url'] = get_permalink( $item_arr['id'] );
$item_arr['exposer_urls'] = \Tainacan\Exposers_Handler::get_exposer_urls(get_rest_url(null, "{$this->namespace}/{$this->rest_base}/{$item->get_id()}/")); $item_arr['exposer_urls'] = \Tainacan\Exposers_Handler::get_exposer_urls(get_rest_url(null, "{$this->namespace}/{$this->rest_base}/{$item->get_id()}/"));