0

I have here two identical wordpress installations. One is online and one is in a local network environment. Both uses the same database, without modfications. For development purposes I use a mu-plugin, to redirect home/siteurl/plugin URL:

function dev_home() {
    $url = 'https://' . $_SERVER['HTTP_HOST'];
    return $url;
}

function dev_siteurl() {
    $url = 'https://' . $_SERVER['HTTP_HOST']  . '/subfolder';
    return $url;
}

// fixes the plugins_url
function dev_plugins_uri( $full_url, $path=NULL, $plugin=NULL ) {
    return get_option( 'siteurl' ) . substr( $full_url, stripos( $full_url, PLUGINDIR ) - 1 );
}

if (!empty($_SERVER['WP_ENV']) && $_SERVER['WP_ENV'] == 'development') {
    add_filter('pre_option_home', 'dev_home');
    add_filter('pre_option_siteurl', 'dev_siteurl');
    add_filter('plugins_url', 'dev_plugins_uri');
}

The problem is now, when I upload a picture in the admin panel/media tab, it generate the URL for the online version. Witch is good, but for preview I would like to see the pictures also in my local environment.

Is there a special filter for that?

I tested upload_dir, but without success.

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.