bobbingwide / oik-clone

Clone content between sites
https://www.oik-plugins.com/oik-plugins/oik-clone-clone-your-wordpress-content/
GNU General Public License v2.0
5 stars 0 forks source link

Cloning attachments is date sensitive #2

Closed bobbingwide closed 9 years ago

bobbingwide commented 9 years ago

It seems that if you want to clone attachments successfully then you need to do it in the month that you created the content.

I created a number of pages in July with attached images also created in July and/or August. When it came to cloning the pages and their attached media the "attachment" posts and attached files got out of synch. The various image sizes were expected to be in the 2015/07 folder but were actually created in the 2015/08 folder.

Detailed analysis

When you upload attachments to a post then the folder into which they're added is defined by the parent post's date not the current date. So even though the attachment has been created a long time after its parent it will get stored in the upload folder associated with the parent.

In oik_clone_attempt_import() we call oik_clone_save_media_file( $post->post_date ); This is the attachment's post date, not the post date of the attachment's parent.

Proposed solution

Determine the attachment's post month by extracting from the _wp_attached_file post meta data. Create a date from this and use this to pass to oik_clone_save_media_file(). This resolves the original problem but may leave an issue with the metadata associated with different image sizes.

Workaround:

Move the images into the correct folder using ftp.

bobbingwide commented 9 years ago

This problem was fixed in v1.0.0-beta.0817