Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- use this function on gallery_container or whatever the class name is of your gallery's surrounding element to turn a gallery whose link does not go directly to the image as expected by colorbox
- this effectively creates a colorbox for any set of images with only slight modifications made to the function if required
- */
- init_colorbox( );
- function init_colorbox( ){
- $('.gallery_container img').unwrap('a');
- //replace the thumbnail indicator ('_t') + extension in an image with the file extension
- // so that the image that is displayed in colorbox is the large image and not the thumbnail
- //eg: foo_t.bar becomes foo.bar
- $('.gallery_container img').each(function( ){
- $(this).wrap('<a href="' + $(this).attr('src').replace(/_t\.(\w+)$/, '.$1') + '" rel="cb-gallery" />');
- });
- $(".gallery_container a[rel='cb-gallery']").colorbox({maxHeight: '100%'});
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement