UPDATE: Install Lytebox Image Viewer Widget On Your Blogger Blog

Tuesday, February 09, 2010

A lot of my friends have been asking me how I installed the lytebox image viewer on my blog and I'm pretty sure a lot of blog owners on Blogger would want to have it installed on their template too. I've decided to share this simple hack so that everyone can have a much better way of displaying images to their readers. Don't worry I already took care of most of the manual labor so all you need to do is copy and paste a  bunch of codes. So read on if you want to have this widget.



So what exactly is Lytebox? Here's the definition from the author himself.
Lytebox was written from the Lightbox class that Lokesh Dhakar (http://www.huddletogether.com) originally wrote. The purpose was to write a self-contained object that eliminated the dependency of prototype.js, effects.js, and scriptaculous.js. Since the original version of Lytebox (which released with iFrame support), major modifications have been made to improve performance as well as "Slideshow" support, "Themes" support, HTML content support (as opposed to just images) and many more configurable options that allow you to customize the look and feel of Lytebox.
I know the explanation is a bit on the technical side for the average blogger with little technical know how. It just says this new version of Lytebox supports new ways of displaying images. Aside from just showing the image now you can also do slideshows and even view html files or links with it. There's also some themes you can choose from to blend with the color of your blog (grey(default), blue, green, red and gold). So to make things more clearer here's an example of what happens to an image when Lytebox is applied. Click on the image to see how Lytebox displays the image.

Single Image:

Grouped Images

Slideshow

HTML Links
Demo Link

Now that you've seen what Lytebox can do here's how you can implement it on your Blogger template.

Step 1
Log in to your Blogger account and then go to the "Layout" tab of the blog you want to install Lytebox on. On the "Layout" tab go to "Edit HTML". Click on the image to get a better look.

Step 2
Back up your template first by clicking on "Download Full Template" just in case something goes terribly wrong.

Now look for this code
</head>

Then paste this code right above it:
<!--Code-By-GeekPinoy-->
<link href='http://wimg.co.uk/46k.css' media='screen' rel='stylesheet' type='text/css'/>
<script src='http://wimg.co.uk/HBz.js' type='text/javascript'/>
<!--Code-By-GeekPinoy-->

Go ahead and click on "SAVE TEMPLATE". Now all we have to do is add some codes to tell your template how each image should be shown in Lytebox.

When making a new post add your image then go to "EDIT HTML" in your post editor. Then do the following depending on which one you want to do.

For a SINGLE IMAGE you just have to add this to your image code:
rel="lytebox"

So it should look like this:
<a href="http://i278.photobucket.com/albums/kk93/jabaya/HomerSimpsoniPhone.jpg" imageanchor="1" rel="lytebox" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="107" src="http://i278.photobucket.com/albums/kk93/jabaya/HomerSimpsoniPhone.jpg" width="200" /></a>


For GROUPED IMAGES you add the same rel="lytebox" code but with "[]" and a name or number assigned to the group inside something like rel="lytebox[group1]" or just plainly rel="lytebox[1]". Just don't forget to add rel="lytebox[1]" to each image you want in the group.

<a href="http://i278.photobucket.com/albums/kk93/jabaya/HomerSimpsoniPhone.jpg" imageanchor="1" rel="lytebox[1]" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="107" src="http://i278.photobucket.com/albums/kk93/jabaya/HomerSimpsoniPhone.jpg" width="200" /></a>



If you want to make a SLIDESHOW just go ahead and use this code instead rel="lyteshow[group-name]". Just don't forget to add the code to each image you want on the slideshow.

<a href="http://i278.photobucket.com/albums/kk93/jabaya/HomerSimpsoniPhone.jpg" imageanchor="1" rel="lyteshow[1]" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="107" src="http://i278.photobucket.com/albums/kk93/jabaya/HomerSimpsoniPhone.jpg" width="200" /></a>


You can also view HTML pages using Lytebox by adding rel="lyteframe" to the link code.

<a href="http://www.geekpinoy.com/2010/01/geeks-weekend-life-may-look-like-this.html" rel="lyteframe">Demo Link</a>

That's it! As I said Lytebox also has different colored themes to match the color of your blog. The default color is grey but we have a lot of colors to choose from depending on what you want. Here's how to change theme colors.

On your blogger template look for the code we posted before and change the highlighted code with the code of the color you want:

<!--Code-By-GeekPinoy-->
<link href='http://wimg.co.uk/46k.css' media='screen' rel='stylesheet' type='text/css'/>
<script src='http://wimg.co.uk/HBz.js' type='text/javascript'/>
<!--Code-By-GeekPinoy-->

BLUE:

http://wimg.co.uk/ks3.js


RED:

http://wimg.co.uk/iYC.js


GREEN:

http://wimg.co.uk/XMt.js


GOLD:

http://wimg.co.uk/7E6.js


That's it! I hope you enjoyed GeekPinoy's first tutorial. Let us know how it went for your blog. Happy blogging geeks!

Update: Changed file host since the old one didn't work anymore.


Posted by Jab Escutin
Source and Credits: Lytebox 3.22 by Markus Hay


37 comments:

Prazsky Golem said...

This is a great module, thanks - I noticed something however, the widget doesn't to work with picture uploaded within blogger (the url generated is too long, I guess ?!) so a requirement is to use photobucket or imgur

jab said...

@Prazsky Golem - hhhmmm... never actually tried it with an image from blogger... i'll check on it and update this post... thanks for the heads up!

Luuk said...

Hi, does it only work with the seize: height="107" and width="200"?? Because i can not get it to work if i keep the original size..

jab said...

@luuk - hhhmmm... the script automatically resizes the image when you view it in lytebox, so it should work even if you keep the original size... can you post the image code here so I can check?...

kenwooi said...

thanks for sharing the guide! cool stuff!

jab said...

@kenwooi - give it a go and let me know how it works for you...

Luuk said...
This post has been removed by the author.
jab said...

@Luuk - if that's the case I think it all depends on your blog's template... if the area for your post is too small than you won't be able to put all the images side by side... have you tried using the html codes directly from photobucket?... if you use blogger editor to add your images I know it will provide it's own format and alignment of the images...

Luuk said...

hmm ok, when i use a direct html code from photobucket. Like this, see picture for snapshot:

http://i275.photobucket.com/albums/jj290/dumbl3/South%20America/snap15-03-2010-023332pm.png

How do i get the lytebox effect? I don´t know where to put the lytebox code?

jab said...

you used the IMG tag... you have to use the HTML Code... then you can insert rel="lytebox[1]" right after each the a...

hope that helps...

Luuk said...

ps, how do i check if my blog template is wide enough? This is my blog:
luukvth.blogspot.com

Can i not just devide the width of my template in 3, and use that as the width of my pictures?? (a little less maybe, because it looks nicer to have a little bar between the pictures..)

jab said...

just try to experiment with different image widths until you get a nice fit... but you have to do everything manually... and don't use blogger editor since it will automatically format everything...

Luuk said...

thanks jab, i edited the photos in notepad. And iv fixed it; here is the result:
http://luukvth.blogspot.com/2010/03/lago-verde.html

jab said...

looks great! glad I can help... i'm planning to post new tutorials here so check back when you can... =)

Sarah Pecorino said...

Thanks for the great tutorial! I've been trying to do this for MONTHS so I can have a portfolio page on my blog. One question, though, is there a way to include captions with the images? Thanks again!

Sarah
http://sarahpecorino.blogspot.com

jab said...

@sarah

That's an interesting question. I'll try it out and let you know as soon as I make it work. So please check back once in a while. Thanks!

Robin Sinha said...

Please help me out here!

I've just made a gallery following your wonderful directions and it seems to be working well...

http://robinsinha.blogspot.com/2010/06/test.html

However if I go from a page which is linked to the above...

http://www.robinsinha.com

....then lytebox doesnt work???!!!

Can you help please?

Robin Sinha said...

Sorry, the test link has gone now as I've added my albums properly now.

So... lytebox is working perfectly here -

http://robinsinha.blogspot.com/2010/06/lfw.html

But if I link from my holding page -

www.robinsinha.com

and open the same album (London Fashion Week), it doesn't work....

Any ideas??

Many thanks

jab said...

@robin - i think it's because you only put the javascript code on the blogspot template and not on the custom domain. So when you view the photos on the custom domain there's no javascript to handle lytebox. Try it out and please let me know. Great photos by the way.

Robin Sinha said...

Thanks so much for the prompt reply. I will try that out and let you know how I get on.

Thanks again.

Robin Sinha said...

Hi Jab,

I wonder if you can help again..!

Yesterday my lytebox galleries were working fine, this morning they're not! Now, when I click on an image, it directs straight through to the Photobucket link. If I reset my browser (Safari) it starts working for a while and then stops again. I have also tried it with expolorer and it doesn't seem to be working at all.

Any ideas??

Very frustrated!!

Many thanks

Robin Sinha said...

Sorry, my blogspot:
robinsinha.blogspot.com

Jab said...

@robin - I checked the site and everything seems to be working... Can you let a friend try it out on a different computer?...

Robin Sinha said...

Ah yes it is working! I think it's because I was clicking on the image before the page is fully loaded (slow connection at work).

Many thanks.

RocketLife said...

@Sarah: Add title="Your caption text here." to the link to display a caption in the pop-up.

jab said...

@RocketLife - thanks man! works great!

miss -V- said...

Hello there,

I think it doesn't work with quite big images. They don't load. Check it out here-->

http://cockasnook.blogspot.com/search/label/David%20Sykes

Any suggestions?

jab said...

@miss-V-

I checked on the page source and you haven't put the "lytebox" tag on any of the images...

if ever it still doesn't work you might want to put the images on an image host like photobucket... some peeps are reporting that it doesn't work when the images are directly uploaded to blogger...

miss -V- said...

I had to remove the rel="lytebox" since it was not loading. I guess the problem is that these images are bigger that it is allowed for the lytebox to work. It works just fine on my other images all uploaded on picassa/ blogger.

jab said...

you might want to try uploading them to photobucket... I have some images here that's bigger than what you have on your site and they load just fine...

Alakazam said...

@PrazskyGolem - blogger when inserting a picture (sometime) is adding "1600-h" in the path for the picture (e.g: http://1.bp.blogspot.com/_QlTEdTbHnzw/Smf_B2HA4LccxxxAAAACCo/6q84XnVhZSw/s1600-h/doodidoo.jpg) ; that's the reason lytebox show an empty blank square and seems to load forever - just remove the extra "-h" and the lytebox module should work fine

Alakazam said...

@jab Man, thanks so much for this module - kudos

jab said...

@Alakazam - No prob... Just sharing what I can... Thanks for the input on the blogger uploaded images... =)

Bombom Coral said...

Perfect! Thank you very much for this. I've been searching for like... half hour, none of the scripts i've been testing worked.

:]

Mama Matunda said...

Thanks for the great tutorial!

Ishuda A. said...

Geekpinoy!, Thanks for this cool little code, I used it in our group blog! Salamat!

http://culturenext.blogspot.com

Jab said...

@ishuda - glad I can help.