My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
FAQ  
Frequently Asked Questions
Phase-Support, Featured
Updated Nov 19, 2009 by christophe.beyls@gmail.com

Is Slimbox able to display Flash content (like videos), iFrames or other content?

No, Slimbox has been designed from the ground up to display images only, to be simple and to have the smallest code. However, some people have created Slimbox derivatives that implement these features. Because it's open source, you are free to modify the code to fit your needs, as long as you respect the terms of the licence and keep the credits.

Can Slimbox automatically resize my images when they are too large to be contained in the browser window?

Slimbox should not be used to display very large images. The general rule is that the images that you want to show with Slimbox must never exceed the width of your website template. You need to create reduced-size versions of your large images before displaying them with Slimbox.

Why?

First, very large images are better handled by the browser itself when opened in a dedicated window: usually in this case the browser will show the image progressively while it's loading and will automatically resize it to fit the browser window which is exactly what you want.

Second, Slimbox preloads images and only shows them when they are completely loaded. For very large images, this takes some time and this is bad for the user experience. Then, when the image is eventually loaded and shown, next and previous images of the gallery will start to preload too, even if the user does not intend to see them, thus it will use a lot of bandwidth on your website.

Third, dynamically resized images look pixellated in most browsers.

And finally, dynamic image resizing would make the Slimbox code very complex and there is actually no way to make it work flawlessly. Here's a quick technical explanation (you may skip it to avoid headaches):

  • The borders around the images in Slimbox can be freely adjusted in the CSS, so Slimbox cannot determine its own width or height until the resize animation is complete. But then it's too late because we need to know the size in order to launch the animation. And I don't want to hardcode the borders dimensions in the javascript code like Lightbox does, because I prefeir to keep the design part in the CSS file.
  • The caption under the image would ideally need to be fully visible too. It has a variable height and this height cannot be computed until it is displayed (it depends on the used font, the margins, the number of text lines, and so on), but again it's too late.
  • Even if the height is adjusted at the end of the animation so that the caption becames fully visible, then the width must be adjusted too in order to preserve the aspect ratio of the image. But if the width is reduced, the caption's height may increase because the text has less available space and could take up more lines. In this case, in order to make the caption fully visible, the height must be reduced again, and the width also, and so on... in a loop until everything is finally able to fit the screen. This effect will look buggy and unpredictable. So we need to forget about making the caption visible without scrolling when the image is automatically resized.

Slimbox display is incorrect on my website (sometimes only in a particular browser). What's wrong?

Most of the time, this is an issue with the CSS of your web page. Check that your CSS rules are valid and do not override Slimbox' CSS rules. In particular, check that there is no margin applied to your <body> and <html> tags, and that you don't override the default appearance of all <div> tags.

If your CSS is correct, you may have invalid or malformed HTML code. Don't expect Slimbox to work well in web pages containing two <body> elements, for example.

In particular, Internet Explorer tends to be less tolerant regarding invalid CSS or HTML.

Can I change the Slimbox images, colors, fonts, margins, border sizes?

Yes of course, you just need to edit the values in the CSS file. Slimbox uses CSS instead of javascript whenever possible.

How can I use HTML for the image descriptions?

You can use HTML for the image descriptions without problems. But if you insert HTML markup inside a "title" attribute in your HTML page, you need to replace the following characters:

  • < must be replaced with &lt;
  • > must be replaced with &gt;
  • " must be replaced with &quot;

You don't need to do this if you set the HTML markup for the description programmatically using Javascript (see jQuery API or MooTools API).

You can also write a custom linkMapper function which will grab the whole HTML content of a paragraph in the page for example and use it as a description instead of fetching it from the "title" attribute. This way, you don't need to transform the HTML markup either.

The loading of one of my images in Slimbox takes forever. What's wrong?

This happens when the URL of the image is incorrect or unavailable. Check that the URL is correct and that the server hosting the image is online.

Slimbox does not display images containing parenthesis in their URL. What's wrong?

Parenthesis are invalid characters for URLs. You must use their URL-encoded equivalent instead.

Just replace ( with %28 and ) with %29. You must also replace spaces with %20 or +. Other invalid characters include commas, square brackets, exclamation marks, question marks, semicolons, quotes.

If you are using PHP, the urlencode() function will automatically replace all invalid characters with their URL-encoded equivalent.

Is there a way for the visitors of my website to save the images displayed by Slimbox?

When you right-click on an image displayed in Slimbox, there is no option to save it because it's actually a <div> tag, not an <img> tag.

However if Slimbox is opened by clicking on an image link, your visitors can right-click on that link and choose "save target as..." to save the image.

If it's not enough for you and you want the visitors to be able to save the image from inside Slimbox, you can modify the "autoload code block" so that a link to the image is added automatically after the image caption. This is achieved by defining a linkMapper function (see the jQuery API or MooTools API documentation for more information). The autoload code block is located by default in slimbox.js but may be moved inside the HTML page if you want. Here's the new code:

jQuery version

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
jQuery(function($) {
        $("a[rel^='lightbox']").slimbox({/* Put custom options here */}, function(el) {
                return [el.href, el.title + '<br /><a href="' + el.href + '">Download this image</a>'];
        }, function(el) {
                return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
        });
});

mootools version

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
Slimbox.scanPage = function() {
        $$($$("a").filter(function(el) {
                return el.rel && el.rel.test(/^lightbox/i);
        })).slimbox({/* Put custom options here */}, function(el) {
                return [el.href, el.title + '<br /><a href="' + el.href + '">Download this image</a>'];
        }, function(el) {
                return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
        });
};

window.addEvent("domready", Slimbox.scanPage); 

I'm using sIFR and the sIFR text appears over Slimbox instead of being hidden. How can I fix that?

When calling sIFR.replaceElement(), you must set the "sWmode" parameter to "transparent". Please read the sIFR documentation for more information about how to do this.

Is it possible to open Slimbox in the parent frame when clicking on a link inside an iframe?

(i)frames should be avoided as often as possible. It's generally a bad idea to use them: they are deprecated by the W3C, they make things more complex and slow down page loading.

Note that you can mimic the appearance of an iFrame with the scrollbars using a div block having the CSS property "overflow: auto;" and a fixed width and height. Also, you can change its content using ajax calls.

However, if you really, really want iFrames, there are two ways to do this by modifying the "autoload code block" of the parent frame. By default, this code is located in slimbox.js but you can move it inside the HTML page if you want to. Each way has its own drawbacks and will not work as well as if you were not using iframes.

In both cases, you need to setup the full slimbox in the parent frame (jQuery/mootools + slimbox + css) and you only need to include jQuery/mootools in the child frame (no slimbox or css). If you don't add jQuery/mootools in the child frame, an error will occur when clicking on a slimbox-enabled link.

Solution 1

jQuery version

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
jQuery(function($) {
        function scanFrame() {
                $("a[rel^='lightbox']", this.document).slimbox({/* Put custom options here */}, null, function(el) {
                        return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
                });
        }
        scanFrame.apply(window);
        $.each(window.frames, function() {
                this.onload = scanFrame;
                scanFrame.apply(this);
        });
});

mootools version

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
Slimbox.scanPage = function() {
        function scanFrame() {
                $$($$(this.document.links).filter(function(el) {
                        return el.rel && el.rel.test(/^lightbox/i);
                })).slimbox({/* Put custom options here */}, null, function(el) {
                        return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
                });
        }
        scanFrame.apply(window);
        Array.forEach(window.frames, function(frame) {
                frame.onload = scanFrame;
                scanFrame.apply(frame);
        });
};

window.addEvent("domready", Slimbox.scanPage);

Drawbacks:

  • Slimbox-enabled links will be activated instantly (before the images of the page are fully loaded) in the parent frame only. In the child frames, slimbox links will only be activated after the full content (mainly images) is loaded.
  • Images of each frame will be grouped independently. This means that you can not display all images of the page plus all images of its child frames in one big group, and you can not create groups which include some images from a frame with other images from another frame.
  • The keyboard navigation will not work when you click on a slimbox-enabled link inside an iframe, because the iframe will capture the keyboard events instead of the main frame.

Solution 2

jQuery version

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
jQuery(window).load(function() {
        var $ = jQuery, links = [];
        $.each($.merge([window], window.frames), function() {
                $.merge(links, $("a[rel^='lightbox']", this.document));
        });
        $(links).slimbox({/* Put custom options here */}, null, function(el) {
                return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
        });
});

mootools version

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
Slimbox.scanPage = function() {
        var links = [];
        [window].extend(window.frames).forEach(function(frame) {
                links.extend(frame.document.links);
        });
        $$($$(links).filter(function(el) {
                return el.rel && el.rel.test(/^lightbox/i);
        })).slimbox({/* Put custom options here */}, null, function(el) {
                return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
        });
};

window.addEvent("load", Slimbox.scanPage);

Drawbacks:

  • You will need to wait for the full page content to load (including the content of all its child frames) before all slimbox-enabled links are activated, which is the same limitation the original Lightbox has. But this time you can create image groups spanning accross multiple frames.
  • The keyboard navigation will not work when you click on a slimbox-enabled link inside an iframe, because the iframe will capture the keyboard events instead of the main frame.

Which minification tool are you using for the main Slimbox code?

The best one: YUI Compressor by Julien Lecomte. The code was also written in a way that allows it to be efficiently minified with this tool.

Comment by nico...@lampoulerouge.net, Feb 7, 2009

How opening slimbox from xml

Comment by sarita.p...@gmail.com, Mar 3, 2009

I want to restrict the height of the image in the slimbox. Is it possible? If yes, how?

Comment by enol...@gmail.com, Mar 9, 2009

How do I do multiple galleries? I don't quite understand the included tutorial.

Comment by da.realm...@gmail.com, Mar 16, 2009

Hello,

very nice script! I have the problem that I like to open the same gallery from different links. Every link makes a new "first picture", so if i link 3 times to "1.jpg", the gallery will be "1.jpg 1.jpg 1.jpg 2.jpg 3.jpg ...".

Is there a way to fix this?

Comment by quib...@gmail.com, Mar 27, 2009

I cant make the iframe solution work. The page im modifying has already an Iframe in place and to change it to overflow would take too much time. The slimbox loads only inside the iframe and not in the parent window. Any help?

Comment by johnschram@gmail.com, Apr 9, 2009

Great script. Is there any plans to have error handling for image URL's that do not exist? I implemented it myself but it's buggy.

Comment by andrea.m...@gmail.com, Apr 22, 2009

Hi,

I'm trying to let the script run with images and link created dinamically after the page has been loaded. More, page loaded, then user choose an option on the combo, page content is refreshed loading values from an xml file and I need to add or remove many links from the xml file as well.

Unfortunately your script, as well as other lightboxs I tested, works on html code written and parsed during the load event. I tried to call the scanPage event again without success. How can I solve?

Thanks

Comment by underwat...@gmail.com, May 2, 2009

Is it possible to move the entire window down about 100 pixels? If so, how?

Comment by jella...@gmail.com, Jun 9, 2009

I was wondering if there was any way to make the "Next" and "Previous" tabs stay up rather than appear as a mouseover effect. I know this was possible with the original lightbox but did not find any options or parameters that would allow for it here.

Comment by ole.sta...@gmx.de, Jun 10, 2009

@jellatin:

This can be done in the CSS.

Just look for #lbPrevLink and #lbPrevLink:hover. Copy the background declaration from the latter to the first. Then you do the same with #lbNextLink and #lbNextLink:hover. Now you are done. You can additionaly delete or comment out #lbPrevLink:hover and #lbNextLink:hover.

Summarized you should have something similar to this:

#lbPrevLink {
    left: 0;
    background: transparent url(prevlabel.gif) no-repeat left bottom;
}
#lbNextLink {
    right: 0;
    background: transparent url(nextlabel.gif) no-repeat right bottom;
}

Hope I could help Ole

Comment by S.Ag...@gmail.com, Jul 2, 2009

How can you show Next and Previous as text links in lbBottom?

Comment by franco...@gmail.com, Jul 2, 2009

Is it possible to add a print button that prints the picture and caption only?

Comment by tuyen.ba...@gmail.com, Jul 13, 2009

The keyboard navigation will not work when you click on a slimbox-enabled link inside an iframe, because the iframe will capture the keyboard events instead of the main frame. <== How to fix this erro?

Comment by tuyen.ba...@gmail.com, Jul 13, 2009

oh. I have fixed this erro. Happy!

Comment by tknte...@gmail.com, Aug 12, 2009

I have used Slimbox since the Slimbox 1.0 days with mootools. Now it is even better using the JQuery library. I just switched to this newer Slimbox 2 version this week. I was already using the JQuery library for my menu, so I saved an extra javascript by switching. Also, the images seem to render more quickly now. The added options are great. I switched on the image loop feature for example. I do wish the images auto-resized to fit a browser window, such as in a netbook, from which I am typing this. However, I realize that would add to the complexity and size of the script, which is only 4 kb minified.

Comment by bishopbl...@gmail.com, Sep 9, 2009

Is there a way to force slimbox from initiating for certain images, such as adding something like slimbox='no' to the HTML?

Comment by i...@cmykreative.com, Sep 16, 2009

Is it possible to use this script to open a YouTube? video in the lightbox? If so, how would I go about doing it? :)

Chris

Comment by escargot...@gmail.com, Sep 16, 2009

How do you place an outside link in the caption of the image? i.e. the mutt (want mutt to link to www.google.com)

Comment by mr.yu...@gmail.com, Sep 22, 2009

Is there an optimal file size and is there a file size limitation. For example would 200K be too large? Take care, Travis

Comment by Carol.Wo...@gmail.com, Sep 29, 2009

How can i install slimbox on blogger?

Comment by mpoi...@gmail.com, Oct 14, 2009

like escargotconcepts, question on Sep 16, 2009

Is there a way to add a link inside the caption area to a URL, or say a pdf file? this would be pretty rad and help out a ton. trying to figure it out.

Comment by mpoi...@gmail.com, Oct 14, 2009

@ escargotconcepts

after some google searching I found an answer to putting a link in the caption area and thought I would just post it for others to use it. I tried it and it works. http://www.onedigitallife.com/2007/01/24/lightbox-slimbox-and-caption-links/

Comment by contactk...@gmail.com, Oct 27, 2009

Thank you so much for this work. It is very strong and well-liked.

I am trying to make the opening transition faster though. I don't want to watch the box stretch open and across before my image is displayed. I just want to click and have the slimbox open showing my picture. No animated transition on open.

I have tried lots of things in the code and the script... what I think SHOULD work has no effect.

Anyone tackle this issue?

Thanks.

Comment by webst...@gmail.com, Nov 14, 2009

I've used your script to modify the "autoload code block" of the parent frame to open Slimbox in the parent frame. http://www.st-moritz-taucha.de/verein/index1.html It's a good result with IE, Firefox doesn't work. I can't find the cause. Can you help?

Comment by project member christophe.beyls@gmail.com, Nov 16, 2009

@escargotconcepts: You can actually insert HTML in the "title" attribute but you need to escape special chars like < or > or " by replacing them with HTML entities. When adding Adding HTML to the caption using javascript code, you don't need to do that.

@Carol.Wood7822: like you do for any other website. Edit your blogger template.

@contactklucas: Use a transition duration of 0 or 1 and no effect will be displayed. This is written in the documentation by the way (not this page but the docs describing the options).

for Everybody: Don't post you questions on this page, use the forum. http://groups.google.com/group/slimbox-support

Comment by jamsess...@gmail.com, Jan 25, 2010

I am using your jquery code to save the image. I'd like to add a link to download the High Quality image too, just adding the "hq" of the pic name (URL) to the "el.href". How can i get this name change? Thanks.

Comment by harn...@gmail.com, May 12, 2010

I don't know if this is possible, but can you have a set but only have a single image displayed, like an album cover, but once you click, be able to click through the set? Example: I want 50 images in my set, however, I don't want all 50 images shown on the page, can I just show the first image for activating slimbox, then click through the rest of the 49?

Comment by carlos%w...@gtempaccount.com, May 31, 2010

Hello. is there any way to put the close butoon at top of the frame instead of the bottom?

Comment by ckgar...@gmail.com, Jun 8, 2010

ditto precisely what harnatc asked. I've been looking for something that can do that, too.

Comment by Hammerju...@gmail.com, Jun 20, 2010

I have modified the script to allow horizontal scrolling (for large images). Download that version here

Comment by jerryrus...@gmail.com, Jul 8, 2010

Is there a way to change the size and position of the box that says "Loading" when the thumbnails are loading on the page? It's the box that displays the text from this line in the pwi1.0.js file... pwi_labels["loading"] = "LOADING IMAGES...";

Comment by to.inqui...@gmail.com, Aug 2, 2010

Chris, Install "Like you would on any website". What an idiotic response. Not enough fibre in your diet i suppose. Have you considered the possibility that this person does not have knowledge on how to install it at all? I teach people quite a few things, and try to put myself in their position. Try a bit of that, than perhaps, people might not be inclined to say that programmers are good at what they do but quite moronic at logic-application when applied elsewhere.

ed

Comment by AngelSmi...@gmail.com, Aug 2, 2010

@to.inquisitor, lol. I couldn't agree more.

Comment by randy.oy...@gmail.com, Sep 2, 2010

Is it possible to create a set by only displaying one image, then letting the user navigate through the whole set with the arrow keys or next and prev links? That is, the rest of the photos don't show on the website except for the very first one?

Comment by seo...@gmail.com, Sep 9, 2010

Hello all :) I am looking for a way to close the image just by clicking on it in addition to click outside the image. Is it possible ? Somebody know which code I should use for that ?

Thanks in advance

Comment by antoni...@gmail.com, Sep 12, 2010

Why is there in the zipfile 2 times the file: slimbox2.js? In which one do I have to make adjustments?

Comment by war...@gmail.com, Sep 17, 2010

How can I track individual image views using i.e. Google Analytics ?

Comment by pierluig...@gmail.com, Oct 13, 2010

I need to call a function when slimbox open (click event on image thumbs) and another function when the user close it. How i can do this?

Comment by tgom.d...@gmail.com, Nov 22, 2010

I'm currently using slimbox on a website but i have a bug. The slimbox doesn't fit to the image's size. Example on this page : http://www.savoie-mont-blanc.com/nos-suggestions/bouger/activites-velo/les-defis-du-cyclogrimpeurs-1572-1.html. Bug under Chrome 7.0.517.44 and Mac OS 10.6.5 but also under Chrome 7.0.517.44 and Win XP. Anyone have already this malfunction ? ( Slimbox 1.71a with mootools 1.2.4 )

Comment by zeeshi...@gmail.com, Dec 5, 2010

$$($$("a").filter(function (el) {return el.rel && el.rel.test(/^lightbox/i);})).slimbox is not a function

I am getting this error in joomla how can i handle it.

Thanks

Comment by heena.ah...@gmail.com, Dec 8, 2010

How to open slim box on load of page???????help me

Comment by libna...@gmail.com, Dec 10, 2010

Add the following code (based on your framework) into your pages’s <head> tags.

Mootools: <script type="text/javascript"> window.addEvent(“domready”, function() {

Slimbox.open(“image-to-load.jpg”, “image caption”);
}); </script>

jQuery: jQuery(function($) {

$.slimbox(“image-to-load.jpg”, “image caption”);
});

Comment by ericbrug...@gmail.com, Feb 4, 2011

I've got a tiny markup problem (using todays downloaded version).

see image: http://www.plaatjesupload.nl/bekijken/3473520.html

how to fix this?

Comment by avowebs...@gmail.com, Apr 2, 2011

Slimbox on iPad only shades half the screen while lightbox does the whole screen.

Comment by StephenP...@gmail.com, May 12, 2011

@andrea.m

I resolved a similar problem by declaring "<script type=\"text/javascript\" src=\"js/slimbox2.js\"></script>" again in the dynamic pictures that were loaded. There is nothing similar to initLightbox() (like lightbox has) that I found for slimbox.

Comment by al.iac...@gmail.com, Jun 28, 2011

Is it possible to download the larger images? Clicking the right side of the mouse doesn't appear "save image as ..." with IE or Chrome ; this is possible only with the miniature (small image). A. Iacono

Comment by theimpri...@gmail.com, Aug 29, 2011

How can i install slimbox in gallery 2 and replace with lightbox to popup thumbnails

Comment by sptfir...@gmail.com, Nov 12, 2011

How can I print an image inside the slimbox?

Comment by jessica....@gmail.com, Nov 15, 2011

Hi, I installed slimbox 2 on a website and it worked fine. (www.estherberesfordmuravyeva.com/art_commissions_murals). I have now installed it on my own site, doing exactly the same things, and I've checked the script again and again, and it just doesn't want to work this time... any clues??

My site is www.jessicaibbotson.com/drawings

Please help...!

Comment by karet...@gmail.com, Nov 30, 2011

Hi, is there a way to show the close box at the top instead of at bottom? Thanks

Comment by Caitlin_...@hotmail.com, Jan 2, 2012

Lovely code. BUT it won't allow me to make the original graphic that links to the slimbox as a rollover. I submit the rollover coding against the graphic in a variety of different ways, and I'm getting no luck. I want the viewer to know that these links are more than just a small graphic on the page, I want them to be rollovers therefore more noticeable, SO, how do I do this? Thanks, Cat


Sign in to add a comment
Powered by Google Project Hosting