Commit a18becaf authored by frjo's avatar frjo
Browse files

Bug fix for theme_colorbox_imagefield, missing field name. Including some...

Bug fix for theme_colorbox_imagefield, missing field name. Including some extra js files for forms and the default style.
parent 484c080b
......@@ -18,7 +18,7 @@ define('COLORBOX_PATH', 'sites/all/libraries/colorbox');
function colorbox_theme() {
$theme = array(
'colorbox_imagefield' => array(
'arguments' => array('namespace' => NULL, 'path' => NULL, 'alt' => NULL, 'title' => NULL, 'gid' => NULL, 'attributes' => NULL),
'arguments' => array('namespace' => NULL, 'path' => NULL, 'alt' => NULL, 'title' => NULL, 'gid' => NULL, 'field_name' => NULL, 'attributes' => NULL),
'file' => 'colorbox.theme.inc',
),
);
......@@ -166,13 +166,22 @@ function _colorbox_doheader() {
}
drupal_add_js(array('colorbox' => $js_settings), 'setting');
drupal_add_js(variable_get('colorbox_path', COLORBOX_PATH) .'/colorbox/jquery.colorbox-min.js');
$colorbox_file = array('none' => 'jquery.colorbox.js', 'min' => 'jquery.colorbox-min.js');
drupal_add_js(variable_get('colorbox_path', COLORBOX_PATH) .'/colorbox/'. $colorbox_file[variable_get('colorbox_compression_type', 'min')]);
drupal_add_js($path .'/js/colorbox.js');
if ($style == 'default') {
drupal_add_js($path .'/js/colorbox_default_style.js');
}
if (module_exists('image') && variable_get('colorbox_auto_image_nodes', 0)) {
drupal_add_js($path .'/js/colorbox_image_module.js');
}
if (variable_get('colorbox_form', 0)) {
drupal_add_js($path .'/js/colorbox_form.js');
}
if ($user->uid == 0 && variable_get('colorbox_login', 0)) {
drupal_add_js($path .'/js/colorbox_login.js');
}
......@@ -204,6 +213,7 @@ function colorbox_link_alter(&$links, $node) {
'preview',
'thumbnail',
);
// Add a colorbox class to the image link sizes on the image node.
foreach ($sizes as $size) {
$links['image_size_'. $size]['attributes']['class'] = "image image-{$size} colorbox";
$links['image_size_'. $size]['href'] = $node->images[$size];
......
......@@ -42,11 +42,13 @@ function theme_colorbox_formatter_imagefield($element) {
$item['data']['title'] = $node->title;
}
// Shorten the title when it is too long or it will look bad.
if (drupal_strlen($item['data']['title']) > 75) {
$item['data']['title'] = drupal_substr($item['data']['title'], 0, 70) .'...';
}
}
// Shorten the title when it is too long or it will look bad.
if ((variable_get('colorbox_style', 'default') != 'default') && (drupal_strlen($item['data']['title']) > 75)) {
$item['data']['title'] = drupal_substr($item['data']['title'], 0, 70) .'...';
}
// Build the gallery id.
$nid = $item['nid'] ? $item['nid'] : ($node->nid ? $node->nid : '');
switch (variable_get('colorbox_imagefield_gallery', 1)) {
......@@ -65,7 +67,7 @@ function theme_colorbox_formatter_imagefield($element) {
}
list($namespace, $presetname) = explode('][', $element['#formatter'], 2);
if ($preset = imagecache_preset_by_name($namespace)) {
return theme('colorbox_imagefield', $namespace, $item['filepath'], $item['data']['alt'], $item['data']['title'], $gallery_id);
return theme('colorbox_imagefield', $namespace, $item['filepath'], $item['data']['alt'], $item['data']['title'], $gallery_id, $element['#field_name']);
}
}
}
......@@ -87,7 +89,7 @@ function theme_colorbox_formatter_imagefield($element) {
* optional drupal attributes array. If attributes is set, the default imagecache classes
* will not be set automatically, you must do this manually.
*/
function theme_colorbox_imagefield($namespace, $path, $alt = '', $title = '', $gid = '', $attributes = NULL) {
function theme_colorbox_imagefield($namespace, $path, $alt = '', $title = '', $gid = '', $field_name = '', $attributes = NULL) {
if (!empty($path)) {
$image = theme('imagecache', $namespace, $path, $alt, $title, $attributes);
if ($presetname = variable_get('colorbox_imagecache_preset', 0)) {
......@@ -96,7 +98,7 @@ function theme_colorbox_imagefield($namespace, $path, $alt = '', $title = '', $g
else {
$link_path = file_create_url($path);
}
$class = 'colorbox imagefield imagefield-imagelink imagefield-'. $element['#field_name'];
$class = 'colorbox imagefield imagefield-imagelink imagefield-'. $field_name;
return l($image, $link_path, array('html' => TRUE, 'attributes' => array('title' => $title, 'class' => $class, 'rel' => 'gallery-'. $gid)));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment