The default media upload path in WordPress is actually hidden inside the database, with no direct setting visible in the admin dashboard. This article documents my complete walkthrough for changing the default media upload directory, including direct database adjustments and batch-replacing legacy image URLs across existing posts using SQL.

Method 1: Define UPLOADS in wp-config.php

The simplest way is to add the following line to wp-config.php:

/* define( 'UPLOADS', 'images' ); */

However, this alters the relative path of the uploads directory. If you already have existing image assets and paths, this can cause broken links and unnecessary confusion. For that reason, I opted for direct database configuration instead.

Method 2: Modify the wp_options Table

First, navigate to your database management tool (such as phpMyAdmin) and locate the wp_options table → click the table → select Search → set the operator to LIKE %…% → enter upload in the value field → execute the search.

The query will return several results. To modify the default storage directory, click Edit next to upload_path (which is typically left blank by default):

  • upload_path: The absolute server file path for media uploads /home4/willicv1/public_html/images/uploads (the designated image directory)
  • upload_url_path: The custom URL or subdomain path https://images.williamformosa.com/uploads

Save and execute the changes.

Once entries exist for these fields in wp_options, you can navigate in WordPress to Settings > Media > Uploading Files to review the active paths and make further edits directly from the dashboard. (Why WordPress hides these fields by default until they exist in the database remains a mystery!)

Method 3: Batch Update Legacy Post Image Paths via SQL

Open your database SQL console, update the domain and subdomain values in the two queries below to match your own setup, and run them. This will instantly replace all legacy file paths in existing posts with your new subdomain paths:

UPDATE wp_posts SET post_content = REPLACE(post_content,'http://www.domain.com/wp-content/uploads','http://img1.domain.com/uploads');
UPDATE wp_posts SET guid = REPLACE(guid,'http://www.domain.com/wp-content/uploads','http://img1.domain.com/uploads');

Once the query completes, open your WordPress Media Library to verify that images render correctly. If any images fail to display, check your FTP server to confirm the files reside in the corresponding directory. If you have images hardcoded in sidebar widgets, manually update their URLs. That’s all there is to it!

Summary

Changing the default WordPress media upload path boils down to configuring two crucial records in the wp_options table: upload_path and upload_url_path. Once updated, remember to run SQL REPLACE commands to batch update image references in older articles, then verify that the media library and site widgets display properly. While WordPress doesn’t expose these options in the dashboard out of the box, following these straightforward steps makes the migration seamless.

✦ Independent Journalism · Reader Support ✦

Support Independent Perspectives & In-Depth Insights

Every thoughtful analysis and candid critique comes from our dedication to truth and quality. We choose not to follow sensational algorithms or clickbait headlines.

Sustaining independent research requires reader support. Make a one-time or monthly contribution, securely processed by Google.

Payments secured by Google · Manage or cancel anytime in your Google Account