You are here

function theme_views_rss_fields_element in Views RSS 7

Element template

1 theme call to theme_views_rss_fields_element()
theme_views_rss_fields_item in views/views_rss_views_fields.theme.inc
Element template

File

views/views_rss_views_fields.theme.inc, line 87

Code

function theme_views_rss_fields_element($variables) {
  $key = $variables['key'];
  $value = $variables['element'];
  if ($key == 'enclosure') {

    // file exists
    if (isset($value['#raw'][0])) {
      $file = (array) $value['#raw'][0]['raw'];

      // Media field
      if (isset($value['#raw'][0]['rendered']['file']['#entity_type']) && $value['#raw'][0]['rendered']['file']['#entity_type'] == 'media') {
        $style = str_replace("styles_file_", "", $value['#raw'][0]['rendered']['file']['#formatter']);
        $url = image_style_url($style, $file['uri']);
      }
      else {
        if (isset($value['#raw'][0]['rendered']['#image_style'])) {
          $url = image_style_url($value['#raw'][0]['rendered']['#image_style'], $file['uri']);
        }
        else {
          $url = file_create_url($file['uri']);
        }
      }
      return '<enclosure url="' . $url . '" length="' . $file['filesize'] . '" type="' . $file['filemime'] . '" />';
    }
  }
  else {
    return "<{$key}>" . check_plain(htmlspecialchars_decode($value['#markup'])) . "</{$key}>";
  }
}