Articles of upload dir

Disable to create folders for every years and months in uploads folder

How can I disable to create folders for every years and months in uploads folder? I mean there is a lot of folder under “wp-content/uploads”, and the majority of them are empty. Why create WP these folders? Thanks!

Rename image during upload using date and time stamp?

I am trying to rename images during upload to avoid problems with image file names containig special characters and file names with non-latin characters. I found this function to rename images in WordPress: function sanitize_file_uploads( $file ){ $file[‘name’] = sanitize_file_name($file[‘name’]); $file[‘name’] = preg_replace(“/[^a-zA-Z0-9\_\-\.]/”, “”, $file[‘name’]); $file[‘name’] = strtolower($file[‘name’]); add_filter(‘sanitize_file_name’, ‘remove_accents’); return $file; } add_filter(‘wp_handle_upload_prefilter’, ‘sanitize_file_uploads’); […]

Force Uploads Use Yearmonth to off (0) for all existing sites in Multisites

In WordPress Multisite, by default the site option Uploads Use Yearmonth Folders is on (set to 1). Is it possible to force this value for all existing sites in the Network? Perhaps a hook? I know that for new sites created one can use: function simplify_upload_folder($blog_id){ switch_to_blog($blog_id); update_option(‘uploads_use_yearmonth_folders’, false); restore_current_blog(); } add_action(‘wpmu_new_blog’, ‘simplify_upload_folder’); But what […]

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

Proper way to change the path of uploads folder for existing WordPress site

Until now I have used default WordPress directory structure, however since I started using GIT, I plan to setup WordPress as a submodule and also change the paths of upload folder. Since the path for existing images is already set in the database, is there a way to change them automatically?

Images in upload folder with hexadecimal names

I’m using WordPress 3.4.1 with the Suffusion theme 4.3.0. I’ve noticed that there are a large number of images with hexadecimal names, like 54f96e1d5f478186f66bde9d6aeda625.jpeg. I’m wondering how these images are being created, and what I can do to prevent their generation, as they don’t seem to be used by any post.

Organizing media uploads

One of my clients wants to transfer his WordPress website to my server. The problem is his website doesn’t use sub-folders in his upload folder, and he has more than 1,000,000 files in the root of his upload folder. Is there a way to organize all his post uploads into folders, without losing the attached […]

upload files dynamically to user folders

we have several users on our site. we have created a separate folder for each user. Admin have a select box to select users on the site. we have to give ability to upload files to that particular user on selection. I have created a hook to upload_dir. its working fine with the logged in […]

How to upload image from front end and save in media library?

I am working on a plugin .I want to upload image from front end i.e by input type=”file”.I did lot of google for it but could not upload image .Here is my code for uploading image <form method=”post” action=”options.php”> <input type=”file” name=”my_image_upload” id=”my_image_upload” multiple=”false” /> <input type=”hidden” name=”post_id” id=”post_id” value=”55″ /> <?php wp_nonce_field( ‘my_image_upload’, ‘my_image_upload_nonce’ […]

Change WordPress' media upload URL?

This isn’t the usual “How do I change the media upload folder?” question. Our entire site is run through a CDN. The CDN drops POST requests with a 5-6MB file so the WordPress uploads fail. I can work around this I think by changing where WordPress sends file upload requests. If the normal site URL […]