function _convert_to_external_file in Views RSS 8.2
Convert CDN internal name to external name.
3 calls to _convert_to_external_file()
- views_rss_core_preprocess_item_enclosure in modules/
views_rss_core/ views_rss_core.inc - Preprocess function for item <enclosure> element.
- views_rss_core_preprocess_item_guid in modules/
views_rss_core/ views_rss_core.inc - Preprocess function for item <guid> element.
- views_rss_core_preprocess_item_link in modules/
views_rss_core/ views_rss_core.inc - Preprocess function for item <link> element.
File
- modules/
views_rss_core/ views_rss_core.inc, line 448 - Preprocess functions for Views RSS: Core Elements module.
Code
function _convert_to_external_file(&$filename, $force_http = TRUE) {
// Strip /sites/ if it exists at the beginning of the filename.
if (preg_match('/^\\/sites\\/\\//', $filename)) {
$filename = preg_replace('/^\\/sites\\//', '', $filename);
}
// If the filename begins with / then add the url.
if (preg_match('/^\\/[^\\/]/', $filename)) {
$filename = $GLOBALS['base_url'] . $filename;
}
// If the filename begins with // then add the scheme.
if (preg_match('/^\\/\\//', $filename)) {
$scheme = \Drupal::request()
->getScheme();
if ($force_http) {
$scheme = 'http';
}
$filename = $scheme . ":" . $filename;
}
}