0

I have two WP sites (two WP instances). One is the new version of the site on the main domain - sitename.com, and another one is old version which I am trying to move on subdomain archive.sitename.com

To save up disc space I thought about leaving all the upload content of old site inside uploads folder of the main domain and loading archive.sitename.com images from that main domain. Both new version and old version of the site should load images from the main domain.

I have tried upload_dir hook. It does change the subdomain upload root to main domain upload root inside the URL, but images are missing the filename and so are not loaded.

Am I missing something?

add_filter('upload_dir', 'change_upload_dir');
function change_upload_dir( $uploadData ){

    $uploadData['url'] = 'https://www.sitename.com/wp-content/uploads';
    $uploadData['baseurl'] = 'https://www.sitename.com/wp-content/uploads';
    if (!empty($uploadData['subdir'])) {
        $uploadData['url'] = $uploadData['url'].$uploadData['subdir'];
    }

    return $uploadData;

}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.