Created
November 16, 2012 16:30
-
-
Save carolineschnapp/4088729 to your computer and use it in GitHub Desktop.
Lightbox all the things
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| jQuery(function() { | |
| jQuery('.rte img').not('a > img').each(function() { | |
| // Matching images that aren't already shown in their original size. | |
| var re = /(_small)|(_compact)|(_medium)|(_large)|(_grande)/; | |
| var src = jQuery(this).attr('src'); | |
| if (re.test(src)) { | |
| // Determining the URL to the original image. | |
| var href = src.replace(re, ''); | |
| // Activating lightbox. | |
| jQuery(this).wrap('<a></a>') | |
| .parent() | |
| .attr('href', href) | |
| .addClass('lightbox') | |
| .colorbox( { | |
| maxWidth:"95%", | |
| maxHeight:"95%", | |
| scalePhotos:true} ); | |
| } | |
| }); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment