I have two requests. They are urgent requests and I would need it before Monday morning.:
<strong>Request 1</strong>
I use a plugin that automatically downloads remote images and save them.
However, after a few months of work I noticed all the images in Media > Library are "unattached"
These images are actually in posts and working.
What I need is a plugin/function that scans all the posts. Find the images in the posts, and attach it to the post.
It is very important that it keeps the exact same path and file name.
---
SIDENOTE:
---
I used this very usefull plugin: [[LINK href="https://github.com/c3mdigital/media-tools-for-WordPress"]]https://github.com/c3mdigital/media-tools-for-WordPress[[/LINK]]
It basically scans posts for external images and re-attach them. NOT something I want. But perhaps you can modify the code somehow to fit what I need. Because this plugin already scans posts via dates, and has a good UI already built in.
I run the normal plugin, and I get this image:
[[LINK href="http://i.stack.imgur.com/VFG9z.png
"]]http://i.stack.imgur.com/VFG9z.png
[[/LINK]]
This is a good sign because it scans the correct Post ID, and it does pick up the correct images and amount of images per post. So not all hope is lost.
Then I tried this:
plugins/media-tools-for-WordPress-master/media-tools.php
If you remove the lines at 525:
if ( stripos( $img, $path ) !== false ) {
$response .= 'Img already in media library<br>';
continue;
}
<strong>It seems to reattach all the files to the correct posts!</strong>
BUT it also <strong>re-downloads </strong>them, so there are <strong>duplicates</strong>. And most importantly, it <strong>renames </strong>them, which should <strong>not </strong>happen. The file name should stay the same as the original. So it should only attach it, not download and rename.
So you can either modify the above plugin. Or just make your own scan and attach function. I'm happy with either.
<strong>Request 2</strong>
Just to take a look at the image auto save function. To make sure it attach images correctly to post. So this won't happen again.
Thanks
<strong>UPDATE</strong>: This is the full code of the plugin I mentioned above. If anyone want to take a shot
[[LINK href="http://pastebin.com/ePERuGjt#"]]http://pastebin.com/ePERuGjt#[[/LINK]]
I want to disable to renaming and re downloading of the images. Just doing the re-attachment part is needed.
Arnav Joy answers:
can you provide me access to your site to look please.
my email is : [email protected]