Can we get uploaded image path in wordpress by filename?
Actually I know the way in PHP that will parse all files in the uploads folder, and matches the each file. But that way will produce high load on server, whenever I will run this script.
Is there any other possible way?
Thanks.
Note: I do not have any posts linked with it. I just have image file name. By that only I need to find the full image uploaded path e.g. http://www.abc.com/wp-content/uploads/2013/02/test.png
I am not 100% sure I understand what you want but…
WordPress treats attached media like a custom post type. The file name, minus the extension, is stored as the
post_title
in the$wpdb->posts
table. So, to get the path just search for the file name minus the extension.You can use
$attid
plusget_attached_file
orwp_get_attachment_image
or other attachment function to the other information you want.May be this can help you. I am not writing in detail as I am not sure if it was the actual question.