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)

By cmsb - July 11, 2012

I have two very basic questions about images here:

1. How do I code / where do I put the code to make small images on my website "clickable", so that they open to a larger image? I didn't see this exact post anywhere, though I saw references to it in other posts. I have several list pages on my website which need clickable images. I also have detail pages which need the same thing - basically, a global function on pictures to make them clickable.

2. Also, how to I make image uploads (jpg, gif, etc) default to a consistent position on the page? (Top right, as per the design of the entire site). I use, and instructed my client to use the Insert Image icon to place an image where it belongs on a page. But to make this image clickable, will this functionality still work? Uploads is different from Insert Image.

I really need an elementary level explanation on these, sorry. Many thanks![unsure]

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: [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.