• I migrated a site via the native importing/exporting tool in WP. I copied over the contents of the uploaded folder via FTP. I then used your plugin to successfully register the media files into the media library, but now they are unattached. This is a problem because I now need to reset the featured image for every post. The Easy Add Thumbnail plugin does that automatically, but only if the images are attached to the posts. It seems easy enough to include a loop in your plugin to, after registering the image to the media library, go through all posts and attach it to the ones that use the image’s url. What do you think?

    https://wordpress.org/plugins/media-from-ftp/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Katsushi Kawamori

    (@katsushi-kawamori)

    Hi andrelevy,

    I do not understand.
    Please write more in detail.

    Hi Andre,

    I am a bit confused myself, from what you’ve wrote, am I correct in believing that you have images attached to posts still but they’re not showing? Otherwise I am unsure how you expect the plugin to ‘go through all posts and attach it to the ones that use the image’s url’.

    Are you sure the image urls have not changed due to the migration and re-upload?

    In this event, I would not expect this to be a recurring process and a one-time php script could quickly run through all your posts and update them accordingly.

    Hi.

    I understand the issue here and have a solution.

    The Issue:
    The issue is that media library items are given a unique Attachment ID number. That Attachment ID number is what attaches images to specific posts, pages, etc. When you move files via FTP and register them to the media library, with Media to FTP, those images are all given a unique Attachment ID. That Attachment ID is auto generated and won’t be the same as the site you migrated from. This is why your posts, pages and images don’t match up with the same attachments and featured images.

    The Solution:
    Use WP Attachment Export. It will export your media library with the same exact Attachment IDs. So when you import those media items to your new site the media items will have the same exact Attachment IDs. Then your posts will be synced to match with the same attached images and featured images.

    I hope that makes sense. So if anybody else reading this or running into the same issue, just know your expecting the wrong thing from this plugin. Use the plugin I mentioned above and export your media library and import it separate from any other media import and you will be fine.

    Also note, that this is not the best way to migrate a site. Their are premium solutions to do so, but if you need a free solution try Duplicator.

    Am I understanding that attachment IDs are not being matched up?
    I had to e put my images is separate folders because of the 1024 Godaddy garbage. The attachment IDs have not been altered. There is no WP Attachment Export. Are you saying that Media From FTP doesn’t preserve the Attachment ID?

    Hi @wintechconsulting

    Yes. Media From FTP is designed to import media library items from the FTP folders. Because those files in those folders are uploaded via FTP, those files did not go through the WordPress upload process and therefore have no attachment id registered to refer to.

    If you want to keep the attachment id’s of your images you need to use…
    WP Attachment Export @ https://wordpress.org/plugins/wp-attachment-export/
    – I just checked and the plugin is still there.
    – If the plugin doesn’t come up for you for some reason, let me know. I can post a link to download it.

    Thanks for your response…
    I didn’t explain my situation. It is not a migration. The images were in another part of the Uploads directory. I had to move them to many directories because of Godaddy’s 1024 files/directory restriction.
    So the Media Library URLs are broken because the images were moved. The attachment IDs should still valid.
    I assumed that Media from FTP will preserve the attachment ID in the Media Library and change the url. Am I wrong?

    Hi, ok.

    Yes, that is wrong. If you register your media items with Media From FTP those image will register a new attachment id because they will go through a fresh WordPress upload/register process. Because you already have media images with those attachment id’s Media From FTP/Wordpress will see those attachment id’s and create new ones in attempt to not overwrite existing image/id’s.

    But, what is sounds like you need is a simple url replace tweak, since that is all that is broken.

    You can do that with Velvet Blues Update Urls.
    – It will allow you type in a new url to replace any existing ones.
    – Example:
    — MyDomain.com/old-images-path/ will now become MyDomain.com/new-image-path/
    – Then every url with the old will have the new.
    – Hopefully you don’t a billion new folder urls to replace, but this is what I do.
    – And you can always test it to see if this is the fix you need by being more specific with the url to be replaced.
    – Example:
    — MyDomain.com/old-path/image-name.png to MyDomain.com/new-path/image-name.png
    – Then you can check if just that image now shows up in your media library like you need.

    I hope that makes sense.

    Let me know.

    I have 9600 images in 12 directories, and I don’t know which is where!
    It sounds as if I would have to write a program that will match each image in the db and alter the url.
    Maybe we can make a bogus Migration process, and override the ‘Media from FTP’ url?

    i have an idea using the Velvet Blues plugin.
    Changing attachements.
    http://www.abc.com/wp-content/uploads/2015/03
    to
    http://www.abc.com/wp_content/uploads/2015/20
    http://www.abc.com/wp_content/uploads/2015/21
    .
    .
    http://www.abc.com/wp_content/uploads/2015/32
    Each run will only change image paths for the image match it finds in the destination folder.
    This should work if I understand that the not founds will be unchanged.

    Hi,

    Yeah, if you have moved image to 12 new folders then you should only need to do 12 find and replace of the urls to match accordingly. Which would feel like a life saver and can take just a few minutes to do.

    Just make sure you have the url’s correct when you change them and keep track and confirm each change, because if you update a url incorrectly, the only way to fix it is to update the wrong url with the new.

    That’s all, just double/triple check before submitting the url change so you don’t add more work for you to do 🙂

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Auto-attach files when registering them to the media library’ is closed to new replies.