Websites and applications
Change the uploads folder and media organisation in WordPress
WordPress normally uses wp-content/uploads for uploads and can organise them into year and month folders. Changing this organisation and changing its path are different operations: neither automatically moves existing files or updates all their links.
Turn off month and year organisation
In Settings > Media, untick Organize my uploads into month- and year-based folders and save.
New uploads will use the base folder without adding year and month. Earlier files must stay in their original paths as long as there are references to them. Unticking the option does not reorganise the existing library.
Change the path associated with the library
Test the change on a clone with a copy of the files and the database. In a single-site installation, you can define it in wp-config.php, before WordPress loads:
define('UPLOADS', 'mis-ficheros');
The path is relative to the WordPress root and does not start with /. Do not duplicate an existing constant. Check permissions and that the destination does not allow uploaded files to run as code. The WordPress uploads reference describes how the path and URL are calculated.
Remote storage plugins or a Multisite network can change that behaviour; do not apply the example without reviewing the specific configuration. Changing the base path can also affect the URLs WordPress generates for earlier attachments, even though it does not move their files.
Migrate the existing library
Take stock of original paths, thumbnails and references before moving anything. Keep the relative structure and prepare a replacement that handles serialised data, first as a dry run on the clone. Do not change GUIDs as a matter of routine.
For example, if you only change the base folder from wp-content/uploads to mis-ficheros, an old file can go from:
https://ejemplo.com/wp-content/uploads/2018/12/hola.gif
to the equivalent destination:
https://ejemplo.com/mis-ficheros/2018/12/hola.gif
Turning off date organisation for new uploads does not mean you can remove 2018/12 from existing paths. Flattening the library would be a separate migration, with possible name collisions and additional metadata changes.
My images do not load after the change
Check the requested URL and the file's actual location. Review originals, thumbnails, srcset, page builder content and CDN versions. An image visible on one page does not prove that all its variants work.
Test a new upload, an old attachment and several pages on mobile. If the previous paths have public links, keep them accessible or redirect them to the equivalent file before retiring them.
To roll back, restore the configuration, files and references from the checked point. Do not delete the previous folder until validation and the recovery period are complete.
You may also find useful
- Deactivate a WordPress plugin without accessing the dashboard Helps you regain access to WordPress through recovery mode or by temporarily renaming the plugin's d...
- Enable WordPress Multisite Explains how to prepare, enable and complete a WordPress Multisite network with subdomains or subdir...
- Have several domains on a single WordPress installation Explains how to point several domains to specific pages of a single WordPress through an alias or ad...
- Order for updating WordPress, WooCommerce, plugins, themes and PHP Organises a safe update of WordPress, WooCommerce, extensions, theme, translations and PHP, with bac...
Something wrong or out of date? Tell us and we will review it.