summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaciej Zgadzaj2012-05-10 12:22:52 (GMT)
committerMaciej Zgadzaj2012-05-10 12:22:52 (GMT)
commit69321d0284f8417a51e463ed4bd0fcd5a3e514e7 (patch)
tree03cd5ad5badba21cc124048893c909fc97f6846e
parent0246c63ad47829ab39dfc05ce4682d8e9e154546 (diff)
Issue #1561506 (and #1498288): <enclosure> formatting for other fields, using 3rd party podcast host (idea by Dan Feidt)
-rw-r--r--modules/views_rss_core/views_rss_core.field.inc12
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/views_rss_core/views_rss_core.field.inc b/modules/views_rss_core/views_rss_core.field.inc
index c810d7f..751e6fe 100644
--- a/modules/views_rss_core/views_rss_core.field.inc
+++ b/modules/views_rss_core/views_rss_core.field.inc
@@ -12,7 +12,7 @@ function views_rss_core_field_formatter_info() {
$formatters = array(
'enclosure' => array(
'label' => t('RSS <enclosure> element'),
- 'field types' => array('file', 'media', 'image'),
+ 'field types' => array('file', 'media', 'image', 'text', 'link_field'),
),
);
return $formatters;
@@ -89,6 +89,8 @@ function views_rss_core_field_formatter_view($entity_type, $entity, $field, $ins
if (
($field['type'] == 'file' || $field['type'] == 'image') && empty($item['fid'])
|| $field['type'] == 'media' && empty($item['file']->fid)
+ || $field['type'] == 'text' && empty($item['safe_value'])
+ || $field['type'] == 'link_field' && empty($item['url'])
) {
unset($items[$delta]);
continue;
@@ -109,6 +111,14 @@ function views_rss_core_field_formatter_view($entity_type, $entity, $field, $ins
$item['filesize'] = $item['file']->filesize;
$item['filemime'] = $item['file']->filemime;
}
+ elseif ($field['type'] == 'text' || $field['type'] == 'link_field') {
+ $uri = ($field['type'] == 'text') ? $item['safe_value'] : $item['url'];
+ // Great idea to use get_headers() here by Dan Feidt,
+ // http://drupal.org/user/60005 Thanks Dan!
+ $headers = get_headers($uri, $format = 1);
+ $item['filesize'] = $headers['Content-Length'];
+ $item['filemime'] = $headers['Content-Type'];
+ }
else {
$uri = file_create_url($item['uri']);
}