You are here

function cdn_basic_get_url in CDN 6

Gets the URL for a file when the basic mode is enabled.

Parameters

$path: The path to get the URL for.

1 call to cdn_basic_get_url()
custom_file_url_rewrite in ./cdn.module

File

./cdn.module, line 342
Implementation of the core hooks, defines, public and private functions.

Code

function cdn_basic_get_url($path) {

  // Ensure the configuration is correct.
  if (variable_get(CDN_BASIC_URL_VARIABLE, FALSE) === FALSE) {
    return FALSE;
  }
  $extensions = str_replace(array(
    ' ',
    '.',
  ), array(
    '|',
    '\\.',
  ), variable_get(CDN_BASIC_EXTENSIONS_VARIABLE, CDN_BASIC_EXTENSIONS_DEFAULT));
  if (preg_match("/({$extensions})\$/", $path)) {
    $base_path = base_path();
    $cdn_url = variable_get(CDN_BASIC_URL_VARIABLE, 'http://yourcdn.com');
    return $cdn_url . $base_path . $path;
  }
  else {
    return FALSE;
  }
}