Download & Extend

Lightbox2 and Gallery2 break Drupal6

Project:Lightbox2
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:tracy_pilcher
Status:closed (fixed)

Issue Summary

Using Lightbox and Gallery2 does not work on a german Drupal6 and german Gallery2 installation. The issue however seems to be created by the lightbox2 module.

The error is that the disclosure indicators (see attached image) won't show and work anymore unless either Lightbox2 or Gallery2 are deactivated.

The debugger shows an error in the page header (parse error):

(broken)

jQuery.extend(Drupal.settings, { "basePath": "/", "admin_menu": { "margin_top": 1, "tweak_modules": 0 }, "lightbox2": { "rtl": "0", "file_path": "/(\\w\\w/)sites/default/files", "default_image": "/sites/default/modules/lightbox2/images/brokenimage.jpg", "border_size": 10, "font_color": "000", "box_color": "fff", "top_position": "", "overlay_opacity": 0,8, "overlay_color": "000", ...

VS

(working)

jQuery.extend(Drupal.settings, { "basePath": "/", "admin_menu": { "margin_top": 1, "tweak_modules": 0 }, "lightbox2": { "rtl": "0", "file_path": "/(\\w\\w/)sites/default/files", "default_image": "/sites/default/modules/lightbox2/images/brokenimage.jpg", "border_size": 10, "font_color": "000", "box_color": "fff", "top_position": "", "overlay_opacity": 0.8, "overlay_color": "000", ...

Notice the overlay_opacity value 0,8 vs 0.8! I don't know where to change the localized number formatting, but I hope this helps.

AttachmentSize
error.jpg56.12 KB

Comments

#1

i have the same problem

#2

what other modules do u have enabled?

#3

Status:active» closed (won't fix)

Marking as "won't fix" as no more information forthcoming. Please feel free to re-open if you can give me more information.

Cheers,
Stella

#4

Status:closed (won't fix)» active

I have the same problem in russian installtion. Using Lightbox2 only. Js debugger shows an error in the page header "invalid object initializer" on the

"lightbox2": { "rtl": "0", "file_path": "/(\\w\\w/)sites/default/files", "default_image": "/modules/lightbox2/images/brokenimage.jpg", "border_size": 10, "font_color": "000", "box_color": "fff", "top_position": "", "overlay_opacity": 0,8, "overlay_color": "000", "disable_close_click": true, "resize_sequence": 0, "resize_speed": 400, "fade_in_speed": 400, "slide_down_speed": 600, "use_alt_layout": false, "disable_resize": false, "disable_zoom": false, "force_show_nav": false, "loop_items": false, "node_link_text": "View Image Details", "node_link_target": false, "image_count": "Image !current of !total", "video_count": "Video !current of !total", "page_count": "Page !current of !total", "lite_press_x_close": "нажмите \x3ca href=\"#\" onclick=\"hideLightbox(); return FALSE;\"\x3e\x3ckbd\x3ex\x3c/kbd\x3e\x3c/a\x3e чтобы закрыть", "download_link_text": "Download Original", "enable_login": false, "enable_contact": false, "keys_close": "c x 27", "keys_previous": "p 37", "keys_next": "n 39", "keys_zoom": "z", "keys_play_pause": "32", "display_image_size": "", "image_node_sizes": "()", "trigger_lightbox_classes": "", "trigger_lightbox_group_classes": "", "trigger_slideshow_classes": "", "trigger_lightframe_classes": "", "trigger_lightframe_group_classes": "", "custom_class_handler": 0, "custom_trigger_classes": "", "disable_for_gallery_lists": true, "disable_for_acidfree_gallery_lists": true, "enable_acidfree_videos": true, "slideshow_interval": 5000, "slideshow_automatic_start": true, "slideshow_automatic_exit": true, "show_play_pause": true, "pause_on_next_click": false, "pause_on_previous_click": true, "loop_slides": false, "iframe_width": 600, "iframe_height": 400, "iframe_border": 1, "enable_video": false }

When i disable Lightbox2 all working. I'm using default Lightbox2 settings.

#5

The problem is localized. Error caused by a peculiarity of the Russian locale. In the Russian locale for the fractional part separated by a comma, not point. As a result, violated the format of the initialization string. I solved the problem as follows:

// Load the javascript settings.
$js_settings = array(
//'overlay_opacity' => (float)variable_get('lightbox2_overlay_opacity', 0.8),
'overlay_opacity' => str_replace(',','.',(float)variable_get('lightbox2_overlay_opacity', 0.8)),

in the lightbox2.module

#6

Assigned to:Anonymous» tracy_pilcher

It's probably a good idea to incorporate this fix to the overlay_opacity percent in the module, since many countries use comma in the place of the period in floats, currency, etc. I will make the change, test it and commit it to the module if it works as expected.

#7

Status:active» fixed

Replaced overlay_opacity array setting with the version recommended by ij3net so that module will be compatible with all localizations.

AttachmentSize
overlay_opacity.patch 1.01 KB

#8

Status:fixed» closed (fixed)

closing ticket.

#9

converting to float is unnecessary

'overlay_opacity' => str_replace(',', '.', variable_get('lightbox2_overlay_opacity', 0.8)),

will have the same result as the previous patch.

here are some tests if you want to experiment with comma used as decimal separator:

<?php
//setlocale(LC_NUMERIC, 'german'); //windows
setlocale(LC_NUMERIC, 'de_DE.utf8'); //linux

var_dump(0.1);
var_dump((float)0.1);
var_dump(str_replace(',', '.', (float)0.1));
var_dump(str_replace(',', '.', 0.1));
var_dump(str_replace(',', '.', '0.1'));
?>

also you may try the print function instead of var_dump..
nobody click here