uid == 1) { return; } $cdn1 = 'http://cdn1.example.com'; $cdn2 = 'http://cdn2.example.com'; $cdn_extensions = array('css', 'js', 'gif', 'jpg', 'jpeg', 'png'); // Most CDN's don't support private file transfers without a lot of hassle, // so don't support this in the common case. if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) { return; } // Serve files without extension and files with one of the CDN extensions // from CDN 1, all others from CDN 2. $pathinfo = pathinfo($path); if (!array_key_exists('extension', $pathinfo) || in_array($pathinfo['extension'], $cdn_extensions)) { $path = $cdn1 . '/' . $path; } else { $path = $cdn2 . '/' . $path; } }