media_handle_sideload on a file already on server

I solved this by simulating a $_FILES array: $file_array = array( ‘name’ => basename( $file_path ), ‘type’ => $url_type, ‘tmp_name’ => $file_path, ‘error’ => 0, ‘size’ => filesize( $file_path ) ); And then $att_id = media_handle_sideload( $file_array, $post_id ); As simple as this..

Choosing images size when uploading

For trivia WP will generate all registered sizes for every image natively. While this doesn’t quite seem optimal, the recommendation (if one might call it that) to deal with it is “get bigger disks”. 🙂 If size isn’t a concern you can just go with it. The typical solution takes a little different angle. Instead … Read more