URL- json, . ( /functions.php), :
function get_thumbnail_url($post){
if(has_post_thumbnail($post['id'])){
$imgArray = wp_get_attachment_image_src( get_post_thumbnail_id( $post['id'] ), 'full' );
$imgURL = $imgArray[0];
return $imgURL;
} else {
return false;
}
}
function insert_thumbnail_url() {
register_rest_field( 'post',
'featured_image',
array(
'get_callback' => 'get_thumbnail_url',
'update_callback' => null,
'schema' => null,
)
);
}
add_action( 'rest_api_init', 'insert_thumbnail_url' );
, ,
{{ post.featured_image }}
: , wp_get_attachment_image_src , .