• Resolved qaws

    (@qaws)


    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

    Thanks.

    • This topic was modified 8 years, 3 months ago by qaws.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter qaws

    (@qaws)

    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.

    • This reply was modified 8 years, 2 months ago by qaws.
    Thread Starter qaws

    (@qaws)

    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;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using Jetpack’s Photon gives null for thumbnails’ is closed to new replies.