| 1 |
|
<?php |
| 2 |
|
// $Id$ |
| 3 |
|
|
| 4 |
|
/** |
| 5 |
|
* @file |
| 6 |
|
* imagefield plugin. |
| 7 |
|
*/ |
| 8 |
|
// Implementation of jcarousel_block_PLUGIN_exists |
| 9 |
|
function jcarousel_block_imagefield_exists($nid) { |
| 10 |
|
$field = variable_get('jcarousel_block_imagefield_name', 'imagefield'); |
| 11 |
|
$field_type = variable_get('jcarousel_block_imagefield_type', 'imagefield'); |
| 12 |
|
|
| 13 |
|
$node = node_load($nid); |
| 14 |
|
if (!$node) { |
| 15 |
|
return false; |
| 16 |
|
} |
| 17 |
|
else if (!$node->$field) { |
| 18 |
|
return false; |
| 19 |
|
} |
| 20 |
|
else if (!is_array($node->$field)) { |
| 21 |
|
return false; |
| 22 |
|
} |
| 23 |
|
else if (!count($node->$field)) { |
| 24 |
|
return false; |
| 25 |
|
} |
| 26 |
|
else { |
| 27 |
|
$field_content = $node->$field; |
| 28 |
|
if (!$field_content[0]['imceimage_path']) { |
| 29 |
|
return false; |
| 30 |
|
} |
| 31 |
|
} |
| 32 |
|
|
| 33 |
|
return true; |
| 34 |
|
} |
| 35 |
|
|
| 36 |
|
// Implementation of _jcarousel_block_PLUGIN_preprocess_images |
| 37 |
|
function _jcarousel_block_imagefield_preprocess_images(&$variables) { |
| 38 |
|
$variables['imagefield_type'] = 'imagefield'; |
| 39 |
|
|
| 40 |
|
$node = $variables['node']; |
| 41 |
|
$field_name = $variables['field']; |
| 42 |
|
foreach ($node->$field_name as $key => $image) { |
| 43 |
|
$thumb_path = imagefield_file_admin_thumb_path($image); |
| 44 |
|
list($width, $height, $type, $image_attributes) = @getimagesize($thumb_path); |
| 45 |
|
$formatted_image = array(); |
| 46 |
|
$formatted_image['path'] = '/'. $image['filepath']; |
| 47 |
|
$formatted_image['thumb_path'] = '/'. $thumb_path; |
| 48 |
|
$formatted_image['rel'] = $variables['image_rel']; |
| 49 |
|
$formatted_image['width'] = $width; |
| 50 |
|
$formatted_image['height'] = $height; |
| 51 |
|
$formatted_image['alt'] = ''; // todo |
| 52 |
|
$variables['images'][] = $formatted_image; |
| 53 |
|
} |
| 54 |
|
} |