Here is the code again:
function dlink_content_set_uploadbase ($content) {
$options = get_option('dlink_settings');
$blog_base = '';
global $blog_id;
$current_blog_details = get_blog_details( array( 'blog_id' => $blog_id ) );
if( !empty($current_blog_details->blogname) ) {
$blog_base = '/'.$current_blog_details->blogname;
}
if ($options['relative']) {
$uploads = wp_upload_dir();
$siteurl = site_url();
if (substr($uploads['baseurl'],0,strlen($siteurl))==$siteurl)
$path=substr($uploads['baseurl'],strlen($siteurl));
else
$path=$uploads['baseurl'];
$content = str_replace('{uploads}', $blog_base.$path, $content);
} else {
$uploads = wp_upload_dir();
$content = str_replace('{uploads}', $uploads['baseurl'], $content);
}
return $content;
}