Colorbox settings are currently not alterable for two reasons:
1. There is no colorbox_settings_alter hook.
2. The settings are hard-wired in the Javascript (namely Drupal.behaviors.initColorbox) because of some minor case differences, like slideshowSpeed:settings.slideshowspeed, etc.
To be able to allow adjusting settings on a page-by-page basis, or add one of the other Colorbox settings that are not supported by this module (which is my use case here), I'd suggest to fix (1) and (2) by passing Drupal.settings.colorbox unaltered but with correct casing, thereby also reducing the size of the Javascript.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | hook_colorbox_settings_alter_820520.patch | 3.04 KB | frjo |
| #4 | 820520-colorbox.patch | 6.2 KB | smk-ka |
| #3 | 820520-colorbox.patch | 6.19 KB | smk-ka |
Comments
Comment #1
smk-ka commentedAlso I fail to understand what the custom settings should be good for, this looks very untypical for a Drupal module. You sure know there is a 'Reset' button on every Drupal settings page that allows users to get the module defaults back, don't you?
Comment #2
smk-ka commentedThis looks also wrong (in _colorbox_doheader()):
Comment #3
smk-ka commentedFirst patch to demonstrate what I had in mind. Other Javascript files than the main colorbox.js still might need to be adjusted.
Comment #4
smk-ka commentedSorry, ignore the last patch, it was outdated and non-working. Correct version attached.
Comment #5
frjo commented#4: The alter_hook and the much smarter way of fixing the settings in "colorbox.js" looks really nice.
How would the settings be done in files like "colorbox_load.js" where some settings is build in functions and some comes from Drupal.settings?
#2: The code from is correct, the styles are located in the Colorbox plugin directory, not the Colorbox module directory.
#1: This was done in an attempt to make the settings page less overwhelming for new users, while still providing all the advanced settings. I sure its room for improvement.
Thanks for contributing this!
Comment #6
frjo commentedPart of this is already committed, the corrections of the setting names. Here is the rest.
Comment #7
hutch commentedI've just tested this patch and it works fine, though I haven't tested the hook alter part, only the js.
As it happens I was just about to provide a patch to allow a slideshow to be invoked from the source html, so I've altered what I was about to post to work with the new way to manage Drupal.settings.
As it would be a patch on a patch I'll just post the code:
Immediately below
add
and use 'colorbox-slideshow' as the class for the grouped images.
Now I have per-instance slideshows :-)
Tested in Imagepicker.
Comment #8
hutch commentedJust to confirm:
The patch in #6 applies cleanly to current dev. My suggested addition to colorbox.js in #7 also works with current dev
Comment #9
hutch commentedI have tested the drupal_alter hook and it appears to work fine, Here is what I did
I'm not sure if this is correct....but it works.
It does however change it for the entire site, not just the instances being used by 'mymodule' so if more than one module has this hook we would have a kind of race condition.
Comment #10
frjo commentedCommitted to 6-dev. Thanks for the patch and the help testing it! This is a really neat and powerful addition to Colorbox.
Please post the colorbox-slideshow as a separate feature request. I would also put it in a separate JS file.