Do you have a multi-site install? Does this install use paths, not subdomains? I was having the same problem, and noticed that the JSON-API for attachments only works on the main blog (residing at ABSPATH)
If you donwload version 1.0.7 (2011-01-27) and use models/attachment.php from that zip, your problem will be resolved.
I will file a bug (and waited way to long to upgrade…)
hth
Nope it’s actually a single site. Turns out if you have a different wordpress install ur; than your site url it could cause this. Turns out the fix is this: https://ww.wp.xz.cn/support/topic/thumbnails-not-included-for-attachment-fix?replies=5
function query_images() {
$sizes = array('thumbnail', 'medium', 'large', 'full');
if (function_exists('get_intermediate_image_sizes')) {
$sizes = array_merge(array('full'), get_intermediate_image_sizes());
}
$this->images = array();
$upload_dir = wp_upload_dir();
foreach ($sizes as $size) {
list($url, $width, $height) = wp_get_attachment_image_src($this->id, $size);
$filename = str_replace( $upload_dir['baseurl'], $upload_dir['basedir'], $url);
if (file_exists($filename)) {
list($measured_width, $measured_height) = getimagesize($filename);
if ($measured_width == $width &&
$measured_height == $height) {
$this->images[$size] = (object) array(
'url' => $url,
'width' => $width,
'height' => $height
);
}
}
}
}
Just replace that function located in models/attachment.php and you will get back your thumbnails (featured image) in JSON API
I guess this is resolved but should be updated according in the actual plugin in a later release.
I had a similar problem, but I’m using the WP Read Only plugin (I’m running WordPress on Heroku). This plugin makes sure all images are uploaded to S3. The thumbnails were null also.
I rewritten the above function and deleted the checks whether the file exists. It works now, but obviously does not check for the file’s existence:
function query_images() {
$sizes = array('thumbnail', 'medium', 'large', 'full');
if (function_exists('get_intermediate_image_sizes')) {
$sizes = array_merge(array('full'), get_intermediate_image_sizes());
}
$this->images = array();
$home = get_bloginfo('url');
$upload_dir = wp_upload_dir();
$basedir = $upload_dir['basedir'];
$file = get_post_meta($this->id, '_wp_attached_file', true);
foreach ($sizes as $size) {
list($url, $width, $height) = wp_get_attachment_image_src($this->id, $size);
$filename = $basedir . '/' . str_replace(basename($file), basename(parse_url($url, PHP_URL_PATH)), $file);
list($measured_width, $measured_height) = getimagesize($filename);
$this->images[$size] = (object) array(
'url' => $url,
'width' => $width,
'height' => $height
);
}
}