Viewing 4 replies - 1 through 4 (of 4 total)
  • Even safer is to use wp_upload_dir();

    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
              );
            }
          }
        }
      }

    using site_url() (not up_upload_dir(), unfortunately) worked for me — thanks!

    I had the same issue – and had to revert to older code that doesn’t check file paths & image sizes – just builds a list of images base on WordPress’s wp_get_attachment_image_src()

    Before making changes to the plugin code, check to see if you have jetpack>photon enabled. It rewrites the thumbnail urls to include the wp.com cdn in such a way that that makes the fileexists check fail.
    I disabled photon and the thumbnail urls reappeared in the JSON feed.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘thumbnails not included for attachment fix’ is closed to new replies.