After digging around, I ended up with using upload_dir
filter.
Here is what I tried in functions.php
to change uploads
to media
. Hope it can help someone too 🙂
add_filter('upload_dir', function($uploads)
{
$custom = [];
foreach ($uploads as $key => $value) {
if ( false !== strpos($value, '/app/uploads') ) {
$custom[$key] = str_replace('/app/uploads', '/app/media', $value);
} else {
$custom[$key] = $value;
}
}
return $custom;
});
Many thanks to @gmazzap for the guidelines and the suggestion about upload_dir
filter!
Related Posts:
- How to move wp-content (or uploads) outside of the WordPress directory
- Limit Media Library to Given Folder
- Automatically wrap post image in div
- media_handle_upload weird thing
- Looking to display non-image files in Gallery with logo specific to file type
- Creating a searchable A-Z listing of hundreds of companies/services
- Could not create directory. /var/www/html/wp-content/plugins/PLUGIN_NAME/
- Syncing Avatars across multisite
- How to re-arrange media uploaded using : media_handle_upload() as per year / month
- Hide upload image fields for the different media upload popups
- How to insert a sitemap within a subsite when using WordPress multisite
- How do you modify the WordPress directory structure?
- Add a InfoBox in the media upload window
- I’m using add_meta_box() but want to include TinyMCE editor *and* Media Uploads for each box
- Integrate wordpress into index page
- WordPress media uploader – upload tabs not hiding
- custom upload directory only for plugin uploads
- problem in uploading attachment to custom directory
- Installing new theme on running site
- How can I stop access of unregistered user in wp-content/uploads directory without using .htaccess file?
- Media Upload not working after hiding some elements from functions.php
- WordPress in a Subdirectory
- How to setup a membership system in WordPress?
- Personalized Gallery what are my options?
- Can’t upload format files on media library
- the temporary save folder is wrong
- Can’t do a src to node modules folder
- Problems with running a 2nd installation of WordPress on my domain?
- Hosing a website within a WordPress directory/folder
- Altered Media Library URLs
- How do I enable the text editer in my WordPress theme? [closed]
- Creating a Treeview Listing of a Directory
- Is there a way to limit multi upload in media upload box?
- Having a forum in a subfolder
- Custom Link In WordPress Media “Attachment Details” Upload Screen
- How can I add a Description column to the media library browser screen?
- Upload files in wordpress
- Custom image sizes ignored in WP 3.5
- WordPress uploads directory. Featured Images storage
- How to disable the PDF preview in the file block by default
- How to: Easily Move a WordPress Install from Development to Production?
- Is there a flowchart for WordPress loading sequence?
- Essential technical features for high-end WordPress web hosting? [closed]
- How to structure a plugin
- How to remove admin menu pages inserted by plugins?
- How to put logs in WordPress
- How to get the Date Format and Time Format settings for use in my template?
- Where are Additional CSS files stored
- Best Practices for Regression Testing WordPress Websites?
- Remove wrapping div and ul from output of wp_nav_menu
- What Is The Use Of map_meta_cap Filter?
- get post author id outside loop
- Custom Walker: how to get ID in function start_lvl
- Creative uses of WordPress [closed]
- How to *remove* a parent theme page template from a child theme?
- How do I make my child theme re-apply the settings that were customised when its parent was active?
- get_template_directory() vs bloginfo( ‘template_directory’ ) vs TEMPLATEPATH
- Multiple Inputs in a Customizer Control
- New WP_Customize API – how does it work under the hood?
- Embedding a SOAP Client into a WordPress Plugin?
- Is there anything that Joomla or Drupal can do that can’t be done in WordPress? [closed]
- Change upload directory for PDF files
- Update widget form after drag-and-drop (WP save bug)
- Data sanitization: Best Practices with code examples
- How to benchmark a WordPress installation? [closed]
- Specific upload folder for PDFs in custom Post type in WP multisite
- Should I delete the default themes?
- Moving WP install from local to live, what about wp_posts GUID?
- Modified wp.media.view.Settings.Gallery in Backbone JS, but editing doesn’t work
- Running Gutenberg React in Development Mode
- Prevent WordPress from automatically installing a new theme each year
- Can we use one WordPress installation for multiple databases, domains and content directories
- Is there a blank theme framework compatible with WP 3.0? [closed]
- Plugin SVN & update API – how are plugins identified?
- Users with custom roles not showing in post author select box
- How to use more than 256MB of memory in the admin?
- How do register_sidebar() and get_sidebar() work together?
- How do you get formatted content of a post using the WordPress API?
- Localization: I want the backend: english and frontend in defined language
- Use a separate upload folder for custom post attachment upload
- Are there any forks of WordPress (and what is different about them)?
- How to Change 404 page title
- Make Custom Metaboxes Collapse by Default
- WordPress Paginate $wpdb->get_results
- Custom maintenance page
- Add button to TinyMCE bar without creating a plugin
- Why do I get the timeout warning?
- How to add a new product type on woocommerce product types? [closed]
- How to include own css on wordpress tinymce editor?
- How to disable page delete
- add button to post edit page when post_status=publish
- how to override woocommerce specific loop or archive-product.php [closed]
- Can upload doc and pdf but not ppt – not permitted for security reasons
- Modify existing plugin function using filter (without modifying the plugin directly)
- WordPress hook before inserting post into database
- Any post install tips after installing WordPress 3.0.1?
- Making Custom Fields Standard in the Admin UI
- Remove WordPress theme from a specific page
- Remote upload file to server B
- Version Control: Entire site or just pieces?