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.
Not sure how to categorize this since it's not a "bug" per se, but lacking from documentation. Posting in case it's helpful to someone else.
This is how I got inline image galleries to work.
- Install colorbox_load
- In theme *.libraries.yml, add the following (not sure if this is actually necessary - the idea is to force colorbox output on every page so we can use it):
dependencies:
- core/drupal.ajax
- colorbox/colorbox - Add images wrapped in a link, as it was done in Drupal 7. Use class="colorbox cboxElement".
- To combine multiple images into galleries, use data-colorbox-gallery="". rel="" doesn't work anymore, even though colorbox documentation says it does and the data-* property isn't documented anywhere.
Example working html:
<a href="/sites/default/files/images/IMG_1531.jpg" class="colorbox cboxElement" data-colorbox-gallery="gallery-beforeafter">
<img src="/sites/default/files/images/IMG_1531-thumb.jpg">
</a>
Comments
Comment #2
jasonschweb CreditAttribution: jasonschweb commentedComment #3
jasonschweb CreditAttribution: jasonschweb commentedComment #4
frjo CreditAttribution: frjo commentedColorbox for Drupal 8 is a image field formatter and nothing more, or less. The extra features like colorbox_load and colorbox_inline can be found in contrib. If you have questions about them please use their issues queues.
Comment #6
Carlos Miranda Levy CreditAttribution: Carlos Miranda Levy as a volunteer commentedRegardless, I can confirm rel="" no longer works and data-colorbox-gallery="" does the trick.
This is not mention in the README.txt of colorbox and neither colorbox_inline or colorbox_load have README.txt files so this information is nowhere to be found other than in this post.
At least, here's where I found it.
Comment #7
4kant CreditAttribution: 4kant commentedThanks jasonschweb.
You showed me the next piece of the drupal 8 puzzle ;-)
Comment #8
bcobin CreditAttribution: bcobin commentedDrupal 9:
Adding the [colorbox cboxElement] class to the image and entering same in NG Lightbox is the only way I found to get it to work.
This isn't documented anywhere, so thanks to @jasonschweb for starting me down the right path.