Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When colorbox is enabled, it seems to add its Javascript to every page on the site, even if it isn't necessary on that page. This is a minor performance hit in any browser, but more importantly it can conflict with other JS-heavy modules.
For example, this breaks the image browser popup for WYSIWYG editors (I think across all editors.) When colorbox is enabled, Chrome reports the errors:
and the user can no longer use the popup to select images to go back into their rich-text editor. Rather than digging around in the unminified colorbox JS, I think it might be more useful to be able to disable colorbox on certain pages. I'm therefore attaching a patch that lets the site admin set a variable 'colorbox_paths_disabled' (using e.g. drush vset) which contains path globs where colorbox needs to be disabled. The variable I propose should be garbage-collected by colorbox_uninstall(), as with all other colorbox variables. Would appreciate feedback on this (minor) patch. Thanks for continued maintenance of the colorbox module! (This work was sponsored by Torchbox.)Uncaught TypeError: Object #
has no method 'live' (jquery.colorbox-min.js:4) Uncaught TypeError: Cannot call method 'show' of undefined (jquery.colorbox-min.js:4)
Comment | File | Size | Author |
---|---|---|---|
colorbox-disable-on-certain-paths.patch.txt | 604 bytes | jp.stacey |
Comments
Comment #1
frjo CreditAttribution: frjo commentedThis is already possible, go to admin/settings/colorbox and at the bottom you find "Advanced settings". By default Colorbox is not active on node edit/add pages.
Comment #2
jp.stacey CreditAttribution: jp.stacey commentedWeird. Our configuration is as per default, so it contains admin*, node/*/edit etc. But we were definitely getting those darn errors.
The site is live now, so it's tricky to play around with it too much, but on a local dev copy I can no longer repeat the problem.
We'll close this ticket and assume for now we can remove this patch, but we'll keep on the lookout. Thanks for responding!
Comment #3
rjmackay CreditAttribution: rjmackay commentedFor anyone else having issues with image browser and colorbox. You need to add
imagebrowser*
into the 'Deactive colorbox on specific pages' configuration.Comment #4
ericmulder1980 CreditAttribution: ericmulder1980 commentedFor elements using ajax callbacks, also add system/ajax to the exclusion list!