-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
99 lines (81 loc) · 4.26 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# PLACE this code in template.php file replacing 'phptemplate' by template name
/**
* OVERRIDES IMAGES TEMPLATE TO TAKE CARE OF EMPTY ALT
*/
function phptemplate_imagefield_formatter_image_plain($element) {
// Inside a view $element may contain null data. In that case, just return.
if (empty($element['#item']['fid'])) {
return '';
}
$field = content_fields($element['#field_name']);
$item = $element['#item'];
$item['data']['alt'] = isset($item['data']['alt']) && !empty($item['data']['alt']) ? $item['data']['alt'] : _phptemplate_image_alt($element);
$item['data']['title'] = isset($item['data']['title']) ? $item['data']['title'] : NULL;
$class = 'imagefield imagefield-'. $field['field_name'];
return theme('imagefield_image', $item, $item['data']['alt'], $item['data']['title'], array('class' => $class));
}
function phptemplate_imagecache_formatter_default($element) {
// Inside a view $element may contain NULL data. In that case, just return.
if (empty($element['#item']['fid'])) {
return '';
}
// Extract the preset name from the formatter name.
$presetname = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_'));
$style = 'linked';
$style = 'default';
$item = $element['#item'];
$item['data']['alt'] = isset($item['data']['alt']) && !empty($item['data']['alt']) ? $item['data']['alt'] : _phptemplate_image_alt($element);
$item['data']['title'] = isset($item['data']['title']) ? $item['data']['title'] : NULL;
$class = "imagecache imagecache-$presetname imagecache-$style imagecache-{$element['#formatter']}";
return theme('imagecache', $presetname, $item['filepath'], $item['data']['alt'], $item['data']['title'], array('class' => $class));
}
function phptemplate_imagecache_formatter_linked($element) {
// Inside a view $element may contain NULL data. In that case, just return.
if (empty($element['#item']['fid'])) {
return '';
}
// Extract the preset name from the formatter name.
$presetname = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_'));
$style = 'linked';
$item = $element['#item'];
$item['data']['alt'] = isset($item['data']['alt']) && !empty($item['data']['alt']) ? $item['data']['alt'] : _phptemplate_image_alt($element);
$item['data']['title'] = isset($item['data']['title']) ? $item['data']['title'] : NULL;
$imagetag = theme('imagecache', $presetname, $item['filepath'], $item['data']['alt'], $item['data']['title']);
$path = empty($item['nid']) ? '' : 'node/'. $item['nid'];
$class = "imagecache imagecache-$presetname imagecache-$style imagecache-{$element['#formatter']}";
return l($imagetag, $path, array('attributes' => array('class' => $class), 'html' => TRUE));
}
function phptemplate_imagecache_formatter_imagelink($element) {
// Inside a view $element may contain NULL data. In that case, just return.
if (empty($element['#item']['fid'])) {
return '';
}
// Extract the preset name from the formatter name.
$presetname = substr($element['#formatter'], 0, strrpos($element['#formatter'], '_'));
$style = 'imagelink';
$item = $element['#item'];
$item['data']['alt'] = isset($item['data']['alt']) && !empty($item['data']['alt']) ? $item['data']['alt'] : _phptemplate_image_alt($element);
$item['data']['title'] = isset($item['data']['title']) ? $item['data']['title'] : NULL;
$imagetag = theme('imagecache', $presetname, $item['filepath'], $item['data']['alt'], $item['data']['title']);
$path = file_create_url($item['filepath']);
$class = "imagecache imagecache-$presetname imagecache-$style imagecache-{$element['#formatter']}";
return l($imagetag, $path, array('attributes' => array('class' => $class), 'html' => TRUE));
}
function _phptemplate_image_alt($element) {
$item = $element['#item'];
if(empty($item['data']['alt'])) {
if(isset($item['data']['description']) && !empty($item['data']['description'])) {
$item['data']['alt'] = $item['data']['description'];
}
else if (isset($item['data']['title']) && !empty($item['data']['title'])) {
$item['data']['alt'] = $item['data']['title'];
}
else if(isset($element['#node']->title)) {
$item['data']['alt'] = $element['#node']->title;
}
else if(isset($element['#node']->node_title)) {
$item['data']['alt'] = $element['#node']->node_title;
}
}
return $item['data']['alt'];
}