copyhackers / airstory-wp

Send your blog posts from Airstory writing software to WordPress for publication.
https://wordpress.org/plugins/airstory
MIT License
4 stars 1 forks source link

Resized images being side-loaded twice, producing duplicate attachments #51

Open stevegrunwell opened 7 years ago

stevegrunwell commented 7 years ago

An Airstory customer has reported a case where the WordPress plugin is creating duplicates of images in the media library each time they export from Airstory to WordPress. This shouldn't be the case, so we need to investigate why it might be happening.

No further details are available from the customer at this time, but contact information is available in the Airstory Slack channel.

Response headers from the user's server:

$ curl -I http://wildstory.com/wp-json/airstory/v1

HTTP/1.1 200 OK
Date: Wed, 28 Jun 2017 18:32:25 GMT
Server: Apache/2.2.29 (Unix) mod_ssl/2.2.29 OpenSSL/1.0.1e-fips mod_bwlimited/1.4
X-Powered-By: PHP/5.4.33
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-Robots-Tag: noindex
Link: <http://wildstory.com/wp-json/>; rel="https://api.w.org/"
X-Content-Type-Options: nosniff
Access-Control-Expose-Headers: X-WP-Total, X-WP-TotalPages
Access-Control-Allow-Headers: Authorization, Content-Type
Allow: GET
Set-Cookie: PHPSESSID=991b83810f0373e8376589535a06f921; path=/
Vary: Accept-Encoding,User-Agent
X-UA-Compatible: IE=edge
X-Content-Type-Options: nosniff
Content-Type: application/json; charset=UTF-8
stevegrunwell commented 7 years ago

I've been unable to reproduce this behavior, but have noted that the "download a separate copy of the original media passed to Cloudinary" logic (see Airstory\Formatting\retrieve_original_media() does result in duplicate copies of images) — it's not being done every time a post is exported, but it does result in two separate attachments.

stevegrunwell commented 7 years ago

Reached out to Marc, the Airstory customer who reported the issue and it appears to not be with subsequent exports but rather the original + resized media being imported as two separate attachments.

Ideally, the original image should be what's imported as an attachment, with the resized version as a thumbnail.

stevegrunwell commented 7 years ago

Work has begun in the fix/duplicate-media branch, but as I'm digging into this I'm seeing that it's going to require a larger change to the way media is treated, in a way I'm not quite comfortable approaching in a patch release.

Since there's no immediate bug (it's functioning as designed, just not in the most optimal way), I'm going to bump this to the 1.2.0 milestone (the next minor release).