delete uploaded file
Use wp_delete_attachment( $post_id ) if you have used wp_insert_attachment() before. $post_id is the attachment ID. If you haven’t used wp_insert_attachment() a simple … unlink( $upload[‘file’] ); … will do it.
Use wp_delete_attachment( $post_id ) if you have used wp_insert_attachment() before. $post_id is the attachment ID. If you haven’t used wp_insert_attachment() a simple … unlink( $upload[‘file’] ); … will do it.
Got it, looking at the source code I came up with this: wp_handle_upload($file_input, array(‘test_form’ => false, ‘mimes’ => array(‘csv’ => ‘text/csv’))); To override the mime types just pass mimes as an array wit the key being the file extension and the value as the mime type.
It should not be a lengthy process. Straight from the web: Right click > Copy image location WordPress: Add Media > From URL Editing a picture: Right click > Copy image Paste into your favorite photo editor (e.g. GIMP) Edit and Save WordPress: Add Media > From Computer Note: with WordPress 3.3 you can also … Read more
Try disabling your plugins directory. I’ve been fixing this repeatedly today. Disabling the plugin directory has, for me, allowed the page to load and complete the upgrade process. I suspect it is a specific plugin doing it but haven’t determined which yet. Update If you have W3 Total Cache 9.5.1 installed, deactivate it and try … Read more
try this: add_filter(‘wp_handle_upload_prefilter’, ‘limit_wp_handle_upload_prefilter’); function yoursite_wp_handle_upload_prefilter($file) { // This bit is for the flash uploader if ($file[‘type’]==’application/octet-stream’ && isset($file[‘tmp_name’])) { $file_size = getimagesize($file[‘tmp_name’]); if (isset($file_size[‘error’]) && $file_size[‘error’]!=0) { $file[‘error’] = “Unexpected Error: {$file_size[‘error’]}”; return $file; } else { $file[‘type’] = $file_size[‘mime’]; } } if ($post_id = (isset($_REQUEST[‘post_id’]) ? $_REQUEST[‘post_id’] : false)) { if (count(get_posts(“post_type=attachment&post_parent={$post_id}”))>3) $file[‘error’] … Read more
The magic is in get_allowed_mime_types() which calls the upload_mimes filter. That is filtering a default array consisting of keys as a non-terminated regular expression of file-extensions and the mapped mime-type as values: array( ‘jpg|jpeg|jpe’ => ‘image/jpeg’, ‘gif’ => ‘image/gif’, ‘png’ => ‘image/png’, ‘bmp’ => ‘image/bmp’, ‘tif|tiff’ => ‘image/tiff’, ‘ico’ => ‘image/x-icon’, …. } so hooking … Read more
I believe those are probably generated by the default WordPress sizes – thumbnail, medium and large. (See Appearance > Media for where those sizes are set). If you want to eliminate the extra image sizes the simplest way might be to eliminate some of your theme’s custom image sizes and use the defaults instead. OR, … Read more
You can’t use a file url in file_exists() like this: file_exists( “http://example.com/wp-content/uploads/Example_Name_2_SM.jpg” ); You should rather use an absolute file path, for example: file_exists( “/absolute/path/to/wp-content/uploads/Example_Name_2_SM.jpg” ); Then you should try $meta = get_post_meta( $post->ID, ‘_meta_example_name’, true ); $file = $upload_basedir . “https://wordpress.stackexchange.com/” . $meta . ‘_7_SM.jpg’; if ( file_exists( $file ) ) { //… } … Read more
Let’s face it in detail: The registered sidebar (with the ID left-sidebar) has two arguments to wrap the whole widget (before_widget and after_widget) which you can output via echo $before_widget and echo $after_widget in your widget (see my version below): <?php // Register sidebar if (function_exists(‘register_sidebar’)) { register_sidebar( array( ‘name’ => ‘Left Sidebar’, ‘id’ => … Read more
There are lots of ways to accomplish a daily picture blog so I’ll just give you how I’d approach it. If I wanted to set up a photoblog on WordPress I’d start with a Flickr account and leverage it (or if you don’t like Flickr for some reason you can also look at PhotoBucket, SmugMug, … Read more