jQuery Lightbox Evolution

Examples

By aeroalquimia

If you have any question that are beyond the scope of this help file, please feel free to join the discussion or email me via my user page contact form. Thanks so much!

Table of Contents

Images
  1. Single Image
  2. Image Gallery
  3. Big Images
  4. Advanced Examples
HTML
  1. Inline Content
  2. Ajax
  3. Flash / SWF
  4. Iframe
  5. Advanced Examples
Videos
  1. Simple Usage
  2. JW Player
  3. Advanced Examples
Maps
  1. Simple Usage
Advanced Examples
  1. Custom Buttons
  2. Shake Effect
  3. Login Box
  4. Open Lightbox via Javascript
  5. Events
  6. Show HTML via javascript
  7. Open gallery via javascript #2
  8. HTML 5 Compatibility
Frequently Asked Questions
Support Notes

Images Back to top

Single Image

<a href="assets/1.jpg" class="lightbox"><img src="assets/m1.jpg" /></a>
<a href="assets/2.jpg" class="lightbox"><img src="assets/m2.jpg" /></a>
<a href="assets/7.jpg" title="Image Description" class="lightbox"><img src="assets/m7.jpg" /></a>

Image Gallery

Galleries are created from elements who have the same "rel" tag.

<a href="assets/5.jpg" class="lightbox" rel="group1"><img src="assets/m5.jpg" /></a>
<a href="assets/6.jpg" class="lightbox" rel="group1"><img src="assets/m6.jpg" /></a>
<a href="assets/9.jpg" class="lightbox" rel="group1" title="Lorem ipsum dolor sit amet..."><img src="assets/m9.jpg" /></a>

Big Images

Big images are resized to be completely visible by default.

<a href="assets/4.jpg" class="lightbox"><img src="assets/m4.jpg" /></a>
<a href="assets/8.jpg" class="lightbox"><img src="assets/m8.jpg" /></a>
Autoresize

You can disable the autoresize, by setting the param lightbox[autoresize]=false.

<a href="assets/8.jpg?lightbox[autoresize]=true"  title="autoresize=true" class="lightbox"><img src="assets/m8.jpg" /></a>
<a href="assets/4.jpg?lightbox[autoresize]=false" title="autoresize=false" class="lightbox"><img src="assets/m4.jpg" /></a>
Maximized

Also, if you want to display the full size image by default, set the param lightbox[maximized]=true.

<a href="assets/4.jpg?lightbox[maximized]=true"  title="maximized=true" class="lightbox"><img src="assets/m4.jpg" /></a>
<a href="assets/8.jpg?lightbox[maximized]=false" title="maximized=false" class="lightbox"><img src="assets/m8.jpg" /></a>
Move

If you don't want the image to move at all when you scroll the page, set the param lightbox[move]=false.

<a href="assets/1.jpg?lightbox[move]=false"   title="move=false" class="lightbox"><img src="assets/m1.jpg" /></a>
Combine!

You can combine those three params in the same url.

<a href="assets/8.jpg?lightbox[maximized]=true&lightbox[autoresize]=false" title="maximized=true; autoresize=false" class="lightbox" rel="big[img1]"><img src="assets/m8.jpg" /></a>
<a href="assets/4.jpg?lightbox[autoresize]=false&lightbox[move]=false"     title="autoresize=false; move=false" class="lightbox" rel="big[img1]"><img src="assets/m4.jpg" /></a>

Advanced Examples

Force Size

<a href="assets/3.jpg?lightbox[width]=400&lightbox[height]=200" class="lightbox"><img src="assets/m3.jpg" /></a>
<a href="assets/6.jpg?lightbox[width]=300&lightbox[height]=200" class="lightbox"><img src="assets/m6.jpg" /></a>
Relative Size

<a href="assets/5.jpg?lightbox[width]=50p&lightbox[height]=50p" class="lightbox"><img src="assets/m5.jpg" /></a>
<a href="assets/2.jpg?lightbox[width]=100p&lightbox[height]=100p" class="lightbox"><img src="assets/m2.jpg" /></a>
Disable AutoResize

<a href="assets/9.jpg?lightbox[autoresize]=false" class="lightbox"><img src="assets/m9.jpg" /></a>
<a href="assets/4.jpg?lightbox[autoresize]=false" class="lightbox"><img src="assets/m4.jpg" /></a>
Open in Modal

Toggle if clicking the overlay shouldn't close Lightbox.

<a href="assets/5.jpg?lightbox[modal]=true" class="lightbox"><img src="assets/m5.jpg" /></a>

HTML Back to top

Inline Content

id="loremipsum" Nullam varius congue fringilla. Curabitur auctor dapibus molestie. Cras malesuada vestibulum lectus, vel ullamcorper nibh tempus lobortis. Donec ipsum magna, malesuada et fringilla eget, placerat ut arcu. Donec aliquet, mauris ut pellentesque tincidunt, massa dolor tempor urna, ac interdum massa nisl id tellus. Maecenas eu nunc varius lorem porttitor faucibus. Suspendisse potenti. Donec ullamcorper vehicula pretium. In aliquam adipiscing mi, rhoncus eleifend felis auctor eu. Aenean et mi vitae ante ultricies pulvinar a vel neque.

Open LoremIpsum | Open LoremIpsum with fixed size (524x178)

<a href="#loremipsum" class="lightbox">Open LoremIpsum</a>
<a href="?lightbox[width]=524&lightbox[height]=178#loremipsum" class="lightbox">Open LoremIpsum with fixed size (500x250)</a>

Ajax

Fixed size (350x170) | Relative size (75% x 50%) | Modal

<a href="examples/ajax-html.html?lightbox[width]=350&lightbox[height]=170" class="lightbox">Fixed size (350x170)</a>
<a href="examples/ajax-html.html?lightbox[width]=75p&lightbox[height]=50p" class="lightbox">Relative size (75% x 50%)</a>
<a href="examples/ajax-video.html?lightbox[width]=640&lightbox[height]=360&lightbox[modal]=true" class="lightbox">Modal</a>

Flash / SWF

<a href="http://www.adobe.com/jp/events/cs3_web_edition_tour/swfs/perform.swf" class="lightbox">flash</a>

Iframe

Open CodeCanyon | Open Localhost Iframe

<a href="http://codecanyon.net/?lightbox[iframe]=true&lightbox[width]=770&lightbox[height]=460" class="lightbox">Open Google</a>
<a href="examples/iframe-html.html?lightbox[iframe]=true&lightbox[width]=350&lightbox[height]=170" class="lightbox">Open Localhost Iframe</a>

Advanced Examples

Open flash in fixed size

<a href="http://www.adobe.com/jp/events/cs3_web_edition_tour/swfs/perform.swf?lightbox[width]=700&lightbox[height]=400" class="lightbox">flash</a>
Ajax with button to close the lightbox

Software license agreement

<a href="examples/ajax-license.html?lightbox[width]=450&lightbox[height]=300&lightbox[modal]=true" class="lightbox">Software license agreement</a>

Videos Back to top

Simple Usage

<a href="http://www.youtube.com/watch?v=aHjpOzsQ9YI" class="lightbox">youtube</a>
<a href="http://www.vimeo.com/12421175" class="lightbox"><img src="assets/m13.jpg" alt=""/>vimeo</a>
<a href="http://www.metacafe.com/watch/yt-nn096G5jek0/coldplay_speed_of_sound_acoustic/" class="lightbox">metacafe</a>
<a href="http://www.dailymotion.com/video/x53dvz_fragma-toca-s-miracle-2008_music" class="lightbox">dailymotion</a>

JW Player

Lightbox Evolution is compatible with JW Player. To read more about JW Player click here.

You can "force" to open a mp4 file with JW Player adding the param force=jwplayer and the size you want to display the video.

<a href="bkaovAYt-364766.mp4?lightbox[force]=jwplayer&lightbox[width]=640&lightbox[height]=480" class="lightbox">JW Player</a>

Advanced Examples

Open video in fixed size and modal

<a href="https://vimeo.com/22469541?lightbox[width]=1280&lightbox[height]=720" class="lightbox">google video</a>
<a href="http://www.youtube.com/watch?v=Mq0j2Ot1NHo&lightbox[width]=610&lightbox[height]=360&lightbox[modal]=true" class="lightbox">youtube</a>

Maps Back to top

Simple Usage

| |

<a href="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=+paris+eiffel&ie=UTF8&hq=eiffel&hnear=Paris,+Ile-de-France,+France&ll=48.855708,2.300434&spn=0.013243,0.042272&z=15&lightbox[width]=610&lightbox[height]=360" class="lightbox">Google Maps</a>
<a href="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=+paris+eiffel&ie=UTF8&hq=eiffel&hnear=Paris,+Ile-de-France,+France&ll=48.856075,2.312021&spn=0.02626,0.084543&z=14&layer=c&cbll=48.85738,2.294552&panoid=CpyaiHG57nbMr8YogDfa0Q&cbp=12,34.51,,0,-2.58&lightbox[width]=610&lightbox[height]=360" class="lightbox">Street View</a>
<a href="http://www.bing.com/maps/?v=2&cp=41.89774457054518~12.471384108066559&lvl=15&sty=r&where1=Rome%2C%20Laz.%2C%20Italy&lightbox[width]=610&lightbox[height]=360" class="lightbox">Bing Maps</a>

Advanced Examples Back to top

Custom Buttons

<style type="text/css">
  .jquery-lightbox-buttons .jquery-lightbox-button-openurl
  {
    background: url(assets/lightbox-new-window.png) no-repeat left top;
    width:30px;
    height:39px;
    float:left;
    display:inline;
    padding:0;
  }

  .jquery-lightbox-buttons .jquery-lightbox-button-openurl:hover
  {
    background: url(assets/lightbox-new-window.png) no-repeat right top;
  }
</style>
<script type="text/javascript">
  jQuery(document).ready(function($){

    $("a.customlightbox").lightbox({
      buttons: [
        {
          'class'     : 'jquery-lightbox-button-openurl',
          'html'      : '<span>open in new window</span>',
          'callback'  : function(url, object) {
            window.location.href = url;
          }
        }
      ]
    });

  });
</script>
<a href="assets/1.jpg" class="customlightbox"><img src="assets/m1.jpg" /></a>
<a href="assets/7.jpg" class="customlightbox"><img src="assets/m7.jpg" /></a>
<a href="assets/9.jpg" class="customlightbox" rel="group2"><img src="assets/m9.jpg" /></a>
<a href="assets/6.jpg" class="customlightbox" rel="group2"><img src="assets/m6.jpg" /></a>
`

Custom Buttons - ThemeForest example

<style type="text/css">
  .jquery-lightbox-buttons .button-themeforest
  {
    font-size:12px;
    font-weight:bold;
    text-decoration:none;
  }

  .jquery-lightbox-buttons .button-themeforest:hover
  {
    text-decoration:underline;
  }
</style>
<script type="text/javascript">
  jQuery(document).ready(function($){
    $("a.themeforest").lightbox({
      buttons: [
        {
          'class'     : 'button-themeforest',
          'html'      : 'Live Preview',
          'callback'  : function(url, object, anchor) {
            title = $(anchor).attr('alt').split('|');
            window.location.href = title[0];
          }
        },
        {
          'class'     : 'button-themeforest',
          'html'      : 'Buy this theme',
          'callback'  : function(url, object, anchor) {
            title = $(anchor).attr('alt').split('|');
            window.location.href = title[1];
          }
        }
      ]
    });
  });
</script>
<a href="assets/17.jpg" class="themeforest" rel="group3" alt="http://themeforest.net/item/freshface-html-css/full_screen_preview/109603|http://themeforest.net/item/freshface-html-css/109603"><img src="assets/m17.jpg" /></a>
<a href="assets/18.jpg" class="themeforest" rel="group3" alt="http://themeforest.net/item/perfect-box-wordpress/full_screen_preview/101974|http://themeforest.net/item/perfect-box-wordpress/101974"><img src="assets/m18.jpg" /></a>

Shake effect

Shake Effect

<a href="examples/ajax-html.html?lightbox[width]=350&lightbox[height]=170" class="lightbox">Shake Effect</a>

jQuery.lightbox().shake();

Login Box

Login Box

<a href="examples/ajax-login.html?lightbox[width]=396&lightbox[height]=120&lightbox[modal]=true" class="lightbox">Login Box</a>

Open Lightbox via Javascript

<input type="submit" class="button" id="lbsingle" value="Open single image"/>
<input type="submit" class="button" id="lbgallery" value="Open gallery"/>
<script type="text/javascript">
  jQuery(document).ready(function($){
  
    $("#lbsingle").click(function() {
      $.lightbox("assets/4.jpg", {
        'width'       : 610,
        'height'      : 458,
        'autoresize'  : false
      });
      return false;
    });

    $("#lbgallery").click(function() {
      $.lightbox(["assets/4.jpg", "assets/3.jpg", "assets/6.jpg"]);
      return false;
    });

  });
</script>

Events

<input type="submit" class="button" id="lbevents" value="Click Me"/>
$("#lbevents").click(function() {
  $.lightbox("assets/2.jpg", {
    'onOpen'  : function() {$("#console").append("<p>Event 'onOpen' fired.</p>");},
    'onClose' : function() {$("#console").append("<p>Event 'onClose' fired.</p>");}
  }, function() {
    $("#console").append("<p>'callback' function fired.</p>");
  });
  
  return false;
});

console:

Events fired:

Show HTML via javascript

<input type="submit" class="button" id="lbhtml" value="Create a div 'on the fly'"/>
$("#lbhtml").click(function() {
  var html = $("<div class='center'><h1>Wow! Amazing!</h1><p>Yes, now Lightbox Evolution supports DOM elements created on the fly.</p></div>");

  $.lightbox(html, {
    width   : 350,
    height  : 150
  });
  
  return false;
});

Open gallery via javascript #2

<input type="submit" class="button" id="lbhtml" value="Click Me"/>
$("#lbcomplex").click(function() {
  $.lightbox([
    {
      href   : "assets/1.jpg",
      width  : 400,
      height : 300,
      modal  : true,
      title  : "Each image will have their own custom options."
    },
    {
      href   : "assets/2.jpg",
      title  : "Wow so Amazing!!"
    },
    {
      href   : "assets/3.jpg",
      title  : "Yep, you can add HTML here. This image shouldn't move.",
      move   : false
    }
  ]);
  
  return false;
});

HTML 5 Compatibility

Options via data- attribute

<a href="assets/5.jpg" class="lightbox" data-rel="gal[1]" data-title="I'm number one." data-options='{"modal": "true"}'><img src="assets/m5.jpg" alt=""/></a>
<a href="assets/6.jpg" class="lightbox" data-rel="gal[1]"><img src="assets/m6.jpg" alt=""/></a>
Clean urls

Open Localhost Iframe

<a href="examples/iframe-html.html" class="lightbox" data-options='{"width":350, "height":170, "iframe": true}'>Open Localhost Iframe</a>

Frequently Asked Questions Back to top

  1. Can I use this script on my client's website?

    Yes. Your license includes the rights to use the script on any one website at a time. If you'd like to use the script as part of a service, please consider purchasing an Extended License.

  2. Can I make modifications to this script?

    Feel free to make any modifications you need. Also feel free to blog about it and show your friends, but please do not redistribute the script with your changes.

  3. Why the script doesn't work?

    Make sure you don't have multiple versions of jquery in your page. Look at the source view in your browser to see what jscripts you are loading.

    For example:

    <script src="crazy_path/jquery.js" type="text/javascript"></script>
    ...
    <script src="crazy_path/jquery.min.js" type="text/javascript"></script>
    ...
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
    

    jquery.js and jquery.min.js are the same script. Delete the last one if you can. Keep only one.

  4. The shadow overlay doesn't stretch to cover full browser window.

    Remove the default margin and padding from the body tag. Add body{ margin: 0; padding: 0; } to your stylesheet.

  5. How to automatically start Lightbox on page load?

    Simply add the following code:

  6. <script type="text/javascript">
      jQuery(document).ready(function($){
      
        $.lightbox("image.jpg");
    
      });
    </script>
    
  7. Why Flash objects appear through overlay?

    By default Flash will overlay any HTML content. This can be prevented by setting the 'wmode' param and embed attribute to 'transparent'.

    For more information from Adobe Support

    AC_FL_RunContent( 'codebase', 'http...', 'pluginspage', 'http...',  'wmode', 'transparent', 'width', '99', 'height', '99', 'src', 'images/home', 'quality', 'high' );
    
    var so = new SWFObject("home.swf", "home", "99", "99", "9", "#222222");
    so.addParam("allowfullscreen", "true");
    so.addParam("allowScriptAccess", "always");
    so.addParam("wmode","transparent");
    
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http..." width="999" height="999">
      <param name="movie"   value="images/home.swf" />
      <param name="quality" value="high" />
      <param name="wmode"   value="transparent" />
      <embed src="images/home.swf" wmode="transparent" width="999" height="999" quality="high" pluginspage="http..." type="application/x-shockwave-flash"></embed>
    </object>
    
  8. Lightbox is positioned incorrectly or behaving strangely in Internet Explorer

    This is likely a doctype issue. This plugin requires a valid doctype and rendering in quirks mode is not supported. Make sure you are using the full doctype declaration to insure rendering in standards mode.

    This abbreviated doctype renders the document in quirks mode for Internet Explorer:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    

    The doctype with URI renders in standards mode for all browsers:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    
  9. How can I open Lightbox from inside a Flash movie?

    In your Flash movie you need to use getURL to call your custom callback function, like so:

    getURL("javascript:jQuery.lightbox('image.jpg')");
    
  10. How can I open Lightbox in parent window from inside an iframe?

    First thing you need to do is install the script in your parent window, but don't initialize it. Don't use jQuery(document).ready, instead, add the code below:

    <script type="text/javascript">
      function frameload(iframe) {
        var doc = iframe.contentWindow || iframe.contentDocument;
        if (doc.document) { doc = doc.document; };
        
        jQuery('.lightbox', doc.body).lightbox();
      };
    </script>
    

    Insert onload="frameload(this);" in your iframe markup.

    <iframe src="iframe_child.html" onload="frameload(this);" width="500" height="500"></iframe>     
    

    When you click an image in the child page, the lightbox will be displayed in your parent page. Remember to remove the script in your child page to avoid any problem.

  11. Any plans for making it available for Wordpress?

    Click !

  12. How can I use JW Player 5 to play MP4 files?

    Use this code:

    <a href="player.swf?file=testmovie.mp4&stretching=exactfit&lightbox[width]=480&lightbox[height]=340" class="lightbox">PLAY VIDEO</a>
    

    Where:

    player.swf = path of the JWPlayer
    testmovie.mp4 = path of the movie file
    
  13. I don't like the fancy animation. Can I disable it?

    Yes.

    <script type="text/javascript">
    $.extend(true, $.lightbox().options, {
      animation: {
        show: {
          duration: 400,
          easing  : "swing"
        },
        close: {
          duration: 200,
          easing  : "swing"
        },
        move: {
          duration: 400,
          easing  : "swing"
        }
      }
    });
    </script>
    

    If you want to use another animation effect, add this file [jquery.easing.1.3.js] to your page and replace "swing", in the previous code, with any easing option which starts with "easeOut".

Support Notes Back to top

To be able to help solve a problem quickly, please read the entries below. I will do my best to assist you. I provide a full range of technical support except:

  1. I don't support 3rd-party code (external plugins, javascripts, flash players, etc.). In those cases you have to contact the authors.
  2. I don't support errors provoked by the strong modification of the original packages.
  3. I don't customize the packages in personal way.
  4. If you sure that your improvement ideas will be helpful to others, please don't hesitate to share it with me. Most likely that it will became a free package update.

If you have a more general question relating to scripts on CodeCanyon, you might consider visiting the forums and asking your question in the "Item Discussion" section. Once again, thank you so much for purchasing this plugin.

aeroalquimia (Eduardo Daniel Sada)
Buenos Aires, Argentina. Jul 2010