Here is simple function to create your own sub directory for every upload.
function kv_custom_image_dir( $pathdata ) {
$subdir="/uploads_img".$pathdata['subdir'];
$pathdata['path'] = str_replace($pathdata['subdir'], $subdir, $pathdata['path']);
$pathdata['url'] = str_replace($pathdata['subdir'], $subdir, $pathdata['url']);
$pathdata['subdir'] = str_replace($pathdata['subdir'], $subdir, $pathdata['subdir']);
return $pathdata;
}
add_filter( 'upload_dir', 'kv_custom_image_dir' );
From my above code, I changed my images folder as uploads_img
, you can change yours likewise.
If you want more information, I wrote a tutorial for changing upload directories for every custom upload, take a look at my blog:
Related Posts:
- Saving Custom Field in Attachment Window in WordPress 3.5
- How to add upload video option in wordpress for user?
- How can I create more “create attachment” custom field – any idea?
- Save Custom Meta Value on Media Upload
- Change behavior of “Insert into Post” based on attachment metadata
- Using media-upload.php to upload mp3 via custom fields
- Add new “Insert Into Post” button with another function
- Extend WP Customizer to make multiple image selection possible
- How to save custom fields for attachments
- WordPress custom upload field error
- limit amount of photos uploaded per cpt post
- Metabox with multiple fields added by user and upload box
- Metabox image upload and custom field
- Custom image sizes for custom field media uploads
- wp_handle_upload error “Specified file failed upload test” but still creates attachment?
- Insert attachment ID in custom field from media uploader
- How can I store a file in the database in the same way WordPress and ACF do?
- How do i save and retrieve custom attachment meta?
- Is there a simpler version of WP Media?
- Client PDF Upload (Catalogue) – Automatically update link to PDF
- Custom dropdown field added to media gallery; how to get it to save properly?
- Uploading PDF using Media Uploader
- Select multiple images from custom field
- Redirect to another page using contact form 7? [closed]
- 3.8 Media Upload and Custom Meta Box
- WordPress Media Uploader custom Javascript not working
- How to use media upload on metabox post page without breaking TinyMCE?
- Front-End User Profile
- What’s the best way to add taxonomy’s image in 2017?
- Image upload and path to custom field
- How to delete file uploaded by Plupload
- Problem uploading different files as custom fields with front end post form
- How do I upload file through custom field, save it to database and get it
- Custom field in media library not saving, selected() function not adding “selected” to select list input type
- Can you generate a featured image from two images from custom fields?
- want to add video upload option for front end user
- Adding fields to attachment – only shows when inserting new attachments
- display custom media folders to wordpress media popup
- Custom Meta Boxes and Fields for WordPress: Change directory upload based on user-edit page
- Change path to child of page when uploading image via custom field
- Upload image to wordpress
- Insert wp gallery shortcode into custom textarea
- Multiple image uploader under editor?
- unlink() doesn’t delete the uploaded file
- Media Custom Fields – get a value with PHP
- Permalink structure depending on custom field
- Add nofollow to custom field link and make domain exceptions?
- controlling whether upload is attached to post or not
- change attachment custom field onChange event
- Wrap this custom field with hyperlink link
- Add custom field to post with some part of url as value
- Paying to Access Custom Fields Per Post
- How to diplay a div only if at least one author custom profile field is filled?
- Set custom field value when reaching expiration date
- Get custom fields when hover link of post
- Filter and display a specific custom field value [closed]
- How to split my uploaded media into directories?
- WP_query returns error when used for custom widget
- Adding custom fields to images
- How to save dynamically generated value in post type?
- Is it possible in WordPress
- How can I hide my section title if there is no data in custom fields?
- Set Value To Custom Field While Submit
- Saving metadata of related post on save_post
- Extend WP_Customize_Control with Multiple Field Control
- Related post thumbnail not showing up
- Convert all dates in field to Unix time, except those already in Unix time
- using media_handle_sideload() to add mp4 files to Media Library
- Display different category template if custom field is checked
- Assign one featured image to multiple posts?
- Override edit_custom_walker.php to conditionally show input depending on menu position
- Missing Images in Uploads Directory (Server Only)
- Create download page from post option link
- Custom field in external Javascript
- Add capability for editors to modify custom fields
- Order a query by meta_value and then by post_date
- custom select field populated by allocated post category
- custom field functionality
- How to add custom_fields value in JSON API using create_post
- wordpress simple post multi rating with post_meta and user_meta
- Media Attachment Custom Meta Fields not saving in Media Uploader when using jQuery UI Autocomplete
- How to filter post using custom feild value in shortest and longest duration?
- Metabox with file upload to custom directory
- Custom fields are not displaying in page with multiple loops
- Add class from custom field into widget class
- Custom Field select list is truncated
- Query Posts Via WordPress URL
- CSS conditional on custom field value
- Attachment Metadata not updated while uploading audio files
- How to add an option to admin to add image that could be used as header?
- WP Query multiple select form – meta_query help
- wp_postmeta are updated for only one page
- update_post_meta not working in action hook
- My meta boxes update wp_postmeta of posts but not of pages. What is wrong with the code?
- Confusion on how to display custom field data
- How can I add a Description column to the media library browser screen?
- how to show this part only in the single post page?
- Meta Box Data added to header redirect
- Edit different parts of a page seperately
- How to use page metadata while using wp_list_pages()?