function views_rss_rewrite_relative_paths in Views RSS 6.2
Same name and namespace in other branches
- 8.3 views_rss.module \views_rss_rewrite_relative_paths()
- 8.2 views_rss.module \views_rss_rewrite_relative_paths()
- 7.2 views_rss.module \views_rss_rewrite_relative_paths()
Preprocess callback. Replaces relative paths in element value with absolute URLs. Based on preg_match from rel_to_abs module by lourenzo, with added patch from issue #1335734 by joelstein.
See also
http://drupal.org/project/rel_to_abs
http://drupal.org/node/1335734
3 string references to 'views_rss_rewrite_relative_paths'
- views_rss_core_views_rss_channel_elements in modules/
views_rss_core/ views_rss_core.module - Implementation of hook_views_rss_channel_elements().
- views_rss_core_views_rss_item_elements in modules/
views_rss_core/ views_rss_core.module - Implementation of hook_views_rss_item_elements().
- views_rss_dc_views_rss_item_elements in modules/
views_rss_dc/ views_rss_dc.module - Implementation of hook_views_rss_item_elements().
File
- ./
views_rss.module, line 161 - Module providing fields-based views style plugin for RSS feed generation.
Code
function views_rss_rewrite_relative_paths(&$element) {
// Rewriting relative paths should be enabled by default,
// so rewrite relative paths even if option value is not set.
if (!isset($element['view']->style_plugin->options['feed_settings']['absolute_paths']) || !empty($element['view']->style_plugin->options['feed_settings']['absolute_paths'])) {
global $base_path;
$pattern = '/(src|href)=(\'|")[^\\/]' . preg_quote($base_path, '/') . '/';
$replacement = '$1=$2' . url('<front>', array(
'absolute' => TRUE,
));
$element['value'] = preg_replace($pattern, $replacement, $element['value']);
}
}