dphiffer / wp-json-api

WordPress JSON API
http://wordpress.org/extend/plugins/json-api/
258 stars 181 forks source link

Fixed query_images() for compatibility with Plugin "WP-Offload-S3" #35

Open itinance opened 8 years ago

itinance commented 8 years ago

If the plugin "WP-Offload-S3" is installed, the attachments are stored at AWS S3 and are available either per S3 or via AWS Cloudfront and not necessarily hosted on the server being available at ABSPATH. In this case, file_exists() will check the wrong filepath here. In my PR i'm checking the hostname of the image URLs again the hostname of the wordpress installation and, if they are different, i just pass the information from wp_get_attachment_image_src(), which contains the full path to S3/Cloudfront, and renounce calls to file_exists() and getimagesize().

I reverted the first commit because i forgot to create a branch first.