Warning! Nothing of the proposed below was tested.
add_filter('upload_dir', 'update_attachment_url');
function update_attachment_url($data)
{
$data['url'] = str_replace('http://main-domain/', 'http://sub-domain.com', $data['url']);
$data['baseurl'] = str_replace('http://main-domain/', 'http://sub-domain.com', $data['baseurl']);
return $data;
}
Also you can try to change the values of upload_path and upload_url_path found in the wp_options MySQL table.
Remember to run Search Replace DB to change all published image paths.
Related Posts:
- Where does wordpress store the FTP credentials?
- How to upload a file from WP directory automatically?
- Using dashboard uploader instead of FTP
- Website does not reflect changes on live after uploading files via FTP
- CSS updates appear after delay [closed]
- Do I need FTP set up to upload files to wordpress server
- Updating Media Library PDF’s in bulk
- wp_upload_dir how to get just the directory name .
- Can’t upload media, permissions are correct
- How Can I Organize the Uploads Folder by Slug (or ID, or FileType, or Author)?
- Display attachments by ID in a wp.media frame
- Upload folder is not writable, even when permissions are correct
- Using same directory for storing all uploaded images on a WordPress network
- Contact Form 7 – process form using a PHP script, instead of mailing [closed]
- Where do the favicons for Media Files come from
- Saving images from Gravity Forms repeatable File Upload as post attachments [closed]
- How do I link directly to uploaded files?
- Is wp_read_audio_metadata() function deprecated?
- Uploaded image, but not showing
- WordPress REST Upload Media
- front end post with multiple upload images?
- How to validate the file name of the Media File Uploads?
- Restrict file uploads by extension?
- Add a file type
- WordPress upload file – get path to WordPress installation
- Issue on Running Image upload on WP Metabox Custom Image Loader
- Select image sizes you want to be uploaded
- Check if image exists before uploading with media_sideload_image()
- Plugin to Import Dropbox Files into Media Folder from the Cloud [closed]
- Disable gallery in 3.5 media iframe
- Extend the list of MIME-types supported by the builtin uploader in 3.3
- Setting higher upload limit
- What error logs can I check to see why plugin updates are failing?
- WordPress won’t generate image sizes for certain images
- Resize the WP media Uploader iFrame
- Uploading dwg files to wordpress
- WordPress HTTP Error on File upload
- Images not being generated at correct size
- Remove attachment fields from custom media uploader
- Custom “Insert into Post” button
- How to use MediaUpload outside of editor
- Switch between tabs on “Insert Media” dialog
- Site running slow on new server?
- update_options and unique filenames
- REST API: upload media with advanced custom fields (ACF)
- Prevent a folder from being shown within the media library
- async_upload.php 500 Error when Uploading larger files with slow internet connection and latency
- Is It Possible to Upload Certain Attachment Files To A Remote Server
- WordPress Issue : The uploaded file could not be moved to wp-content/uploads/
- After moving from complete AWS setup to a standalone WordPress Server, Media/Image Files are Broken
- Upload Button in meta box not opening library
- “send_to_editor” function returning pdf file name
- WordPress Media frame pre load images from ids
- How to allow logged out users to upload media?
- Choosing images size when uploading
- One step picture upload
- Alow users to delete uploaded images inside backend?
- add_image_size adds size, but doesn’t upload if source resolution is same as resize resolution
- why can’t upload deb package in my wordpress?
- How to upload media to specific year/month folder
- PHP error when trying to upload .mp3 files via Media Library [closed]
- “page not found” due to hat character (“^”) in a upload file name
- Best way to receive special images in posts
- Provide logo in theme
- Flat media folder vs multiple directories
- Move media files from the root to date folder structure
- How to share /uploads/ directory with another site on the same server?
- Can you limit the size of media files being uploaded not using php.ini?
- wp_upload_bits() is not giving the file path right in localhost
- Deny access to uploads folder with exceptions
- Send media uploads to different directories
- How to make Plupload zones that will survive changes in core?
- Issue when uploading past 8MB?
- How to remove a tab in Media Upload page in wordpress
- How to limit sizes for specific upload programmatically?
- SVG upload does not work
- MIME type not supporting HEIC support type in WordPress
- Unable to upload images into the media library
- How to display the maximum upload size in a WordPress single site?
- wp_handle_upload specified file failed upload test
- How to manually set an attachment in a post?
- What is the hook to obtain the path and the name of the file that is being uploaded?
- Do audio files impact the loading time of the website?
- File upload in WordPress
- Set default “Link CSS Class” in add media admin editor
- How to change default upload dir?
- How could you allow users to upload a video in within their profile and display it on a wordpress site?
- 45mb File Exceeds the Maximum Execution Time
- WP Capabilities to Add Media, Use Media, But Not Edit Them
- Limit attachment caption characters
- Password protected uploaded PDF page
- Why isn’t my enqueuing working properly?
- What is the best way to upload a temporary & sensitive file and then delete it when done
- How do I allow family commenters to upload photos?
- Media Gallery doesn’t show (using WP-Read Only)
- Problem uploading files, after changing domain name
- Unable to upload images using the Media Library
- Image in binary in the data to WordPress media library
- All uploaded files using wp_mail() renamed to tmp_name
- Uploading media from non-local host computer