I have more than 1000 pictures on my webserver, uploaded with FTP in a local folder ( /home/chris/pictures
)
Is there a way to add them as a well known media to wordpress in PHP and get their id?
while ( $the_query->have_posts() ) : $the_query->the_post();
$post_id = get_the_ID();
$filemakerID = get_post_meta($post_id, 'filemaker_id', true);
$file['url']='/home/chris/picture_export/'.$filemakerID.'.jpeg';
$file['type'] = 'image/jpeg';
//THE DREAMED FUNCTION WOULD BE USED THIS WAY
$photo_id = awesome_function( $file, $post_id);
add_post_meta($post_id, 'photo', $photo_id );
}
As you noticed, my photo is used in a custom field photo
as well.
After hours on google dans codex, I noticed how poorly documented these functions are. Maybe I just could not figure out the correct keywords to search.