Given that I upload a file to wp-content/uploads
via FTP, what are the records that I should create in the DB in order for the MediaManager to recognize those new uploads?
Leave a Reply
You must be logged in to post a comment.
Given that I upload a file to wp-content/uploads
via FTP, what are the records that I should create in the DB in order for the MediaManager to recognize those new uploads?
You must be logged in to post a comment.
There is
media_handle_sideload()
function in core meant for processing files not uploaded through media interface.It’s not exactly what you need since it assumes file is outside of uploads and needs to be moved there as part of process, but it should give you and idea on generating and inserting it as valid attachment.
Honestly, I don’t know what the minimum required data is but…
$wpdb->posts
table as anattachment
post type.$wpdb->postmeta
tableunder at least two keys (that I can spot at a glance)–
_wp_attached_file
and_wp_attachment_metadata
.I am sure you will have to populate at least the
$wpdb->post
table. You may be able to neglect some of the post meta, but I don’t know for sure.At any rate, don’t try to construct the data yourself. Crawl the directory and use Core functions to do the work for your, or use a plugin that does it for you, such as this one. I can’t vouch for it but it seems to be close to what you need.