code for when someone clicks on a thumbnail it opens the larger photo in a new window

5 posts by 2 authors in: Forums > CMS Builder
Last Post: July 12, 2012   (RSS)

Re: [cmsb] code for when someone clicks on a thumbnail it opens the larger photo in a new window

By InHouse - July 11, 2012

Hi there,

I'm not sure that I can provide the full detailed explanation you're seeking. That would take a while and also would depend greatly on the specifics of your site. However:

1 - What you're looking for is called a "lightbox". There are many dozens of them available for free or low-cost. Just do a Google search for 'jQuery Lightbox' and you'll find lots of choices to get you started. They all rely on javascript so they use something like the jQuery or MooTools base libraries to work. So you'll have to add those to your site also. There are many tutorials on how to do this online. FWIW, I like FancyBox 2 (http://fancyapps.com/fancybox/) but that is a commercial product. There are lots of excellent free ones.

In a nutshell, after you install jQuery and the lightbox add-on library, you'll follow the lightbox instructions to adjust the anchor/link which wraps your thumbnail so that it triggers the use of the lightbox when clicked. You'll wind up with something that may look a bit like:

<a href="fullSizeImage.jpg" rel="lightbox"><img src="myThumb.jpg"></a>

or

<a href="fullSizeImage.jpg" class="lightbox"><img src="myThumb.jpg"></a>


I don't think you'll want to have this applied to all images on a site or you'll start opening lightbox with every graphical element of your design. However, you can easily make CMSB add the lighbox code to images added to the site via an upload field. For images added by clients via a WYSIWYG editor, you'll have a bigger issue for various reasons. Because of that, we usually create explicit 'upload gallery' fields in our CMSB editors.

2 - The position of your images on your public pages will be determined by where the user inserts the images in the editor and what CSS rules are being applied. This is where seeing the actual site becomes important in order to offer a specific solution. Sorry!

J.

Re: [InHouse] code for when someone clicks on a thumbnail it opens the larger photo in a new window

By cmsb - July 11, 2012

Thank you for your reply, and for your advice. I thought this might be a little easier than installing an add-on but perhaps not. The site I am writing about is www.mtgrovecemetery.org. The client wants the content photographs clickable so that the user can view them larger, with captioning. If you look at the site you'll see photos are all on the right side. That's where I want them to stay, even as uploads. Now they are coded into the body of the content using the wysywig editor.

Many thanks for your ideas.

Re: [cmsb] code for when someone clicks on a thumbnail it opens the larger photo in a new window

By InHouse - July 11, 2012

The pages which have a single image could easily have a lightbox added to them. My approach for all pages with a layout similar to that of: http://www.mtgrovecemetery.org/read_chapelDetail.php would be to:
1 - Create an upload field in the page editor.
2 - Have it create a thumbnail that meets the size you want to display on the page.
3 - On the page code, add jQuery and lightbox libraries.
4 - Use the CMSB Code generator to display the thumbnail in the correct location on the page.
5 - Follow the instructions for that lightbox and make the thumbnail into a link with the required lightbox settings (either class, or rel tag depending on how your lightbox works). That link should point to the full sized image that your client will upload into the CMS.

It sounds worse than it is. The whole process might take 30 mintues. But once done, it can be applied to other pages in seconds.

Hope that helps,
J.

Re: [InHouse] code for when someone clicks on a thumbnail it opens the larger photo in a new window

By cmsb - July 12, 2012

Thank you so much, InHouse. You have been so very helpful and I really appreciate it. I will try the lightbox you recommended.