Articles of uploads

Conditional add_filter for upload directory?

I have a custom media upload button (in the standard post edit page, alongside the standard media upload button), and need to change the upload directory dynamically if this button is clicked – using add_filter(‘wp_handle_upload_prefilter’, ‘my_function’). This post & answer: Conditional add_filter? seem to give the solution, but for some reason don’t work for me […]

wp_handle_upload – The uploaded file could not be moved to wp-content/uploads/2012/09

This is the code I am using to upload the file to WordPress define(‘WP_DEBUG’, true); $filename = “test.png”; $tmpFile = download_url(“”.$filename); chmod($tmpFile, 0755); $mimeType = wp_check_filetype($_SERVER[‘DOCUMENT_ROOT’] . ‘/testing/crop/’.$filename); $file_array = array( ‘file’ => $_SERVER[‘DOCUMENT_ROOT’] . ‘/testing/crop/’.$filename, ‘url’ => $_SERVER[‘DOCUMENT_ROOT’] . ‘/testing/crop/’.$filename, ‘type’ => $mimeType[‘type’], ‘size’ => filesize($_SERVER[‘DOCUMENT_ROOT’] . ‘/testing/crop/’.$filename), ‘name’ => $filename, ‘tmp_name’ => $tmpFile […]

Get attachment ID of author_meta image – Attachment Metadata

I’ve created a custom field in user profile where upload a profile image. It’s very simple. To create fields I’ve used: add_action( ‘show_user_profile’, ‘cover_image_function’ ); add_action( ‘edit_user_profile’, ‘cover_image_function’ ); function cover_image_function( $user ) { <h3>Cover Image</h3> <style type=”text/css”> .fh-profile-upload-options th, .fh-profile-upload-options td, .fh-profile-upload-options input { vertical-align: top; } .user-preview-image { display: block; height: auto; width: […]

What permissions does wp-content/uploads need?

What is the default wp-content/uploads directory permission? What chmod command do I need to set it correctly?

Add metabox with media uploader in a custom post type

This question already has an answer here: Add “upload media” button in meta box field 2 answers

Post type specific upload folder in 3.5

In 3.4 I used the following function to change image upload folder by post type. Different upload directory based on post type in a theme Now it doesn’t work anymore in 3.5. Do you have any idea how to replace this function in 3.5 version? thanks

Need to download uploaded binary file

I have uploaded a binary .war file which is nothing but a .zip file with Java web application extension. When I hit the URL for this file, I see junk characters in browsers. URL: Need a way by which I can make the users download this file. By the way, I uploaded using FTP […]

Automatically wrap post image in div

In regards to image attachments inserted into a post, I would like to wrap the img tag inside a div tag for specific design purpose. Is there a way to do this automatically after attaching the image file, like through hooks/filters maybe? Thanks in advanced!!

Prevent renaming of uploaded media

I would like to upload a PDF file with spaces in it, and I want to do this using the uploader in the rich text editor (really, I want other, less savvy people to be able to do it, so convoluted workarounds are not really an option). Trouble is, WordPress (3.0.3) insists on replacing spaces […]

Custom image upload

I’m trying to setup upload for for attachments for my custom post form. At first I add to my form tag enctype=”multipart/form-data” For testing purposes I have two upload forms, but in future I’m gonna implement only one form and use jQuery to append as many forms as I want. <fieldset class=”images”> <label for=”images”>Front of […]