diff options
author | Silvio <silvio@socioambiental.org> | 2012-10-30 14:58:33 -0200 |
---|---|---|
committer | Silvio <silvio@socioambiental.org> | 2012-10-30 14:58:33 -0200 |
commit | 9998443810c61514741865bf2066bc1caab4708a (patch) | |
tree | c8ad43f9f519179fa87a76623b8fc58bbb801321 | |
parent | da118c5861317a0c9870f2b29aaa9719cd50cf27 (diff) | |
download | timelinejs-9998443810c61514741865bf2066bc1caab4708a.tar.gz timelinejs-9998443810c61514741865bf2066bc1caab4708a.tar.bz2 |
Adding credit and caption for image fields
-rw-r--r-- | timelinejs.module | 4 | ||||
-rw-r--r-- | timelinejs_json_event.tpl.php | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/timelinejs.module b/timelinejs.module index 4971acb..9e284e0 100644 --- a/timelinejs.module +++ b/timelinejs.module @@ -173,3 +173,7 @@ function timelinejs($nid, $width = '960px', $height = '500px') { function timelinejs_print($nid) { return theme('timelinejs_print', timelinejs_fetch_items($nid, 'print')); } + +function timelinejs_strip($string) { + return str_replace(array("\r\n", "\n", "\r"), '<br>', str_replace('"', "'", $string)); +} diff --git a/timelinejs_json_event.tpl.php b/timelinejs_json_event.tpl.php index 1cd0e85..9fd35d9 100644 --- a/timelinejs_json_event.tpl.php +++ b/timelinejs_json_event.tpl.php @@ -1,7 +1,7 @@ { "startDate":"<?php print strftime('%Y,%m,%d', strtotime($event->field_date['und'][0]['value'])); ?>", "headline":"<?php print $event->title; ?>", - "text":"<?php print str_replace(array("\r\n", "\n", "\r"), '<br>', str_replace('"', "'", $event->body['und'][0]['value'])); ?>", + "text":"<?php print timelinejs_strip($event->body['und'][0]['value']); ?>", "asset": { <?php if (!empty($event->field_embed)) { ?> @@ -10,8 +10,8 @@ "caption":"" <?php } else if (!empty($event->field_image)) { ?> "media":"<?php print file_create_url($event->field_image['und'][0]['uri']); ?>", - "credit":"", - "caption":"" + "credit":"<?php if (isset($event->field_image['und'][0]['alt'])) { print timelinejs_strip($event->field_image['und'][0]['alt']); } ?>", + "caption":"<?php if (isset($event->field_image['und'][0]['title'])) { print timelinejs_strip($event->field_image['und'][0]['title']); } ?>" <?php } else { ?> "media":"", "credit":"", |