[wp-hackers] Lookup attachment from file name/path

Paul paul at codehooligans.com
Wed Apr 27 19:51:00 UTC 2011


I have a client who lost their site to a hack (a bad programmer not intruder). Somehow some of the DB references to many of the attachments in the /uploads/ folder are missing. Meaning for any given file under /uploads/ some are  and some are not WP. Would rather not purge everything and reload the tree. Mainly because I would loose the parent association of the current one. And yes there are some 5k attachments in the uploads tree. 

I know there is a function to look up a post/page given the path. But wondering if anyone knows of a way to check if a given file is an attachment?

I know I can load all attachments then check the attachment_url to the path of the file. But to do that for every file seems inefficient. 

P-



More information about the wp-hackers mailing list