| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
include_once('zoomify.inc');
|
| 5 |
|
| 6 |
function zoomify_imagefield_images($node) {
|
| 7 |
$type = content_types($node->type);
|
| 8 |
if (empty($type['fields'])) return null;
|
| 9 |
$images = array();
|
| 10 |
foreach ($type['fields'] as $field) {
|
| 11 |
if ($field['type'] == 'image' && $node->$field['field_name']) {
|
| 12 |
$node_field = $node->$field['field_name'];
|
| 13 |
$images[$node_field[0]['fid']] = $node_field[0]['filepath'];
|
| 14 |
}
|
| 15 |
}
|
| 16 |
return $images;
|
| 17 |
}
|
| 18 |
|
| 19 |
function zoomify_imagefield_field_formatter_info() {
|
| 20 |
$formatters = array();
|
| 21 |
$formatters['zoomify'] = array(
|
| 22 |
'label' => 'Zoomify',
|
| 23 |
'field types' => array('image'),
|
| 24 |
);
|
| 25 |
if (module_exists('imagecache')) {
|
| 26 |
$rules = _imagecache_get_presets();
|
| 27 |
foreach ($rules as $ruleid => $rulename) {
|
| 28 |
$formatters['zoomify]['. $rulename] = array(
|
| 29 |
'label' => 'Zoomify: '. $rulename,
|
| 30 |
'field types' => array('image'),
|
| 31 |
);
|
| 32 |
}
|
| 33 |
}
|
| 34 |
return $formatters;
|
| 35 |
}
|
| 36 |
|
| 37 |
function zoomify_imagefield_field_formatter($field, $item, $formatter) {
|
| 38 |
if (!isset($item['fid'])) return '';
|
| 39 |
$file = _imagefield_file_load($item['fid']);
|
| 40 |
$item = array_merge($item, $file);
|
| 41 |
if ($formatter == 'zoomify') return theme('imagefield_image_zoomify', $field, $item);
|
| 42 |
if (!module_exists('imagecache')) return '';
|
| 43 |
if (strpos($formatter, 'zoomify][') === false) return '';
|
| 44 |
list($null, $namespace) = explode('][', $formatter, 2);
|
| 45 |
$rules = _imagecache_get_presets();
|
| 46 |
if (!in_array($namespace, (array)$rules)) return '';
|
| 47 |
return theme('imagefield_image_imagecache_zoomify', $namespace, $field, $item);
|
| 48 |
}
|
| 49 |
|
| 50 |
function theme_imagefield_image_zoomify($field, $item) {
|
| 51 |
$node = node_load($item['nid']);
|
| 52 |
$pathinfo = pathinfo($item['filepath']);
|
| 53 |
$image = '<img src="'.url(file_directory_path().'/'._zoomify_filepath($node, $item['fid']).'/TileGroup0/0-0-0.'.strtolower($pathinfo['extension'])).'"'.
|
| 54 |
' alt="'.check_plain($item['alt']).'"'.
|
| 55 |
' title="'.check_plain($item['title']).'"'.
|
| 56 |
' />';
|
| 57 |
$output = l($image, 'node/'.$item['nid'].'/zoomify', NULL, NULL, NULL, FALSE, TRUE);
|
| 58 |
return $output;
|
| 59 |
}
|
| 60 |
|
| 61 |
function theme_imagefield_image_imagecache_zoomify($namespace, $field, $item, $attributes = NULL) {
|
| 62 |
$image = theme('imagecache', $namespace, $item['filepath'], $item['alt'], $item['title'], $attributes);
|
| 63 |
$output = l($image, 'node/'.$item['nid'].'/zoomify', NULL, NULL, NULL, FALSE, TRUE);
|
| 64 |
return $output;
|
| 65 |
}
|
| 66 |
|