Forums
Home / Plugin: JSON API / Using Jetpack’s Photon gives null for thumbnails
(@qaws)
8 years, 3 months ago
As the title suggests, if I enable Photon in the Jetpack plugin, I get the following returned from the JSON API when doing a get_posts: "thumbnail":null
"thumbnail":null
Thanks.
8 years, 2 months ago
The code is in models/post.php:
$attachment = $json_api->introspector->get_attachment($attachment_id); $image = $attachment->images[$thumbnail_size]; $this->thumbnail = $image->url; $this->thumbnail_images = $attachment->images;
This should also cater for Photon serving the images.
I changed it to this:
if ( class_exists( 'Jetpack' ) && method_exists( 'Jetpack', 'get_active_modules' ) && in_array( 'photon', Jetpack::get_active_modules() ) ) { $feat_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID)); $this->thumbnail = jetpack_photon_url( $feat_image_url[0] ); } else { $attachment = $json_api->introspector->get_attachment($attachment_id); $image = $attachment->images[$thumbnail_size]; $this->thumbnail = $image->url; $this->thumbnail_images = $attachment->images; }