Why does SVG upload in Media Library fail if the file does not have an XML tag at the beginning?

It seems that in the recent releases of WordPress, changes were made to the mime type handling to make sure that files have the extension they say they do: https://make.wordpress.org/core/2018/12/13/backwards-compatibility-breaks-in-5-0-1/ This poses an issue for SVG files without the tag in them. SVG is actually an XML, and WordPress is now requiring to have a … Read more

Bulk Image Uploader to create new post from each image [closed]

add_action(‘add_attachment’, ‘create_post’); function create_post( $attach_ID ) { $attachment = get_post( $attach_ID ); $my_post_data = array( ‘post_title’ => $attachment->post_title, ‘post_type’ => ‘post’, ‘post_category’ => array(‘0’), ‘post_status’ => ‘publish’ ); $post_id = wp_insert_post( $my_post_data ); // attach media to post wp_update_post( array( ‘ID’ => $attach_ID, ‘post_parent’ => $post_id, ) ); set_post_thumbnail( $post_id, $attach_ID ); return $attach_ID; }

Images in upload folder with hexadecimal names

Testing the plugin provided in this Answer, I just saw that media_handle_sideload generates exactly this pattern, jpeg extension as well (instead of jpg). Following its path through the core, it seems that only the filter wp_handle_upload could be used for dealing with that. But a brief research shows an interesting use of wp_handle_upload_prefilter: Rename files … Read more