jQuery plugin: o3EnlargeBox – display images or other content in-page

Version 1.1.1

Introduction

This plugin allows you to display any DOM element on top of everything else on the screen. It’s great for enlarging images or other media without having to load another page.

Download

v1.1.1 .js .zip .gz

Documentation

Full Documentation

Examples


Note: The bug nicely reported by remco boerma and bert should be fixed as of 1.1.1. I really appreciate their valuable feedback.

This entry was posted in JavaScript, jQuery, Plugin and tagged , , . Bookmark the permalink.

19 Responses to jQuery plugin: o3EnlargeBox – display images or other content in-page

  1. remco boerma says:

    bugreport aka Recipe for failure:
    1. click on the sample image – it opens ok
    1. click again on the sample image – it closes ok
    1. click again on the sample image – it opens failed. border seems displaced

  2. bert says:

    I’ve had the same problem as Remco. I’m using Google Chrome on Windows 7. The first time it opened fine, but after closing the image, whenever I click the sample, the image is docked into the bottom right corner of the browser and the border is stuck in the middle of the browser window with no content.

    • donaldvr says:

      bert,
      Thanks for the comment! I’m working on a fix, but it’s tough b/c I can’t seem to reproduce the problem for myself using Chrome and Windows 7. Do you mind sharing what version of Google Chrome you are using and if you are using any plugins?

      Thanks!

  3. Pingback: 10 freie jQuery-Plugins im Überblick » t3n News

  4. Remco Boerma says:

    The new version works like a charm! Chrome 13.0 (a little outdated maybe) on W7 and not a problem!

  5. eaglejohn says:

    Great plugin! I have a problem on the iPad / Mobile Safari tho:
    When you click on a thumbnail which is positioned quite far from the top, the lightbox will open, but it’s positioned at the top and you have to scroll above to see it.

  6. eaglejohn says:

    Also a problem when you switch your iPad from portrait to landscape mode and vice versa.

  7. eaglejohn says:

    I don’t have the first problem anymore when I’m using it in my app, so that’s problem solved itself. At least, for my situation… :)
    The second one is still there.

  8. eaglejohn says:

    I’m trying to integrate the plugin in WordPress. Is it possible to use an class instead of an class?

  9. eaglejohn says:

    I tried to say img-class and a-class

    • donaldvr says:

      eaglejohn,
      Good question. I’ll try to offer an adequate answer:
      From how I understand it, your question isn’t actually about the plugin itself, but instead the code which calls the plugin. For the examples I used, this code can be found here.
      For an example for your situation, let’s assume that there are images of class “enlargeable” that you’d like to be clickable to use the enlargeBox plugin. And let’s assume that all of those images have “_small” in their filenames and that there are larger versions of those images that have the same filenames except “_small” is replaced with “_large”. You would need the following javascript:

      $(document).ready(function(){
          $('img.enlargeable').click(function(e){
              var that = $(this);        
               var imageSrc = that.attr('src').replace('_small', '_large');
              if ($.browser.webkit) { // this "if" is necessary b/c webkit browsers (Chrome & Safari) don't reliably report correct dimensions for images that have been cached            
                  imageSrc += '?noCache='+Date.now();
              } 
              $('<img src="'+imageSrc+'" />')  // create image DOM element and make src
                  .load(function(){ // assures that enlarged image is loaded ahead of time                
                      var $img = $(this);                
                      $img.o3EnlargeBox({});                                   
                  });
          });
      });
      
      • eaglejohn says:

        Thanks for you reply!

        I edited the JS (go.js) and it works partially for my needs.

        When you place a thumbnail in WordPress, you can link it to the original image. So no need for replacing parts of the filename :-)

        I just tried your suggestion and this happens:

        First the thumbnail is displayed (very quickly) correct in the EnlargeBox, then the original file is being displayed just as an image in the browser.

        PS if you’d like to see my source, just e-mail me for the link.

  10. eaglejohn says:

    I just tried something myself (I’m definitely not a JS-coder):

    $(document).ready(function(){
        $('img.size-thumbnail').click(function(e){
            var that = $(this);
             var imageSrc = that.attr('src').replace('-140x140', '');
            if ($.browser.webkit) { // this "if" is necessary b/c webkit browsers (Chrome &amp; Safari) don't reliably report correct dimensions for images that have been cached
                imageSrc += '?noCache='+Date.now();
            }
            $('')  // create image DOM element and make src
                .load(function(){ // assures that enlarged image is loaded ahead of time
                    var $img = $(this);
                    $img.o3EnlargeBox({});
                });
        });
    
        $('img.size-thumbnail').click(function(e){
            var that = $(this);        
            e.preventDefault(); // prevents link from firing
             var imageSrc = that.attr('href');
            if ($.browser.webkit) { // this "if" is necessary b/c webkit browsers (Chrome &amp; Safari) don't reliably report correct dimensions for images that have been cached            
                imageSrc += '?noCache='+Date.now();
            } 
            $('')  // create image DOM element and make src
                .load(function(){ // assures that enlarged image is loaded ahead of time                
                    var $img = $(this);
                    setTimeout(function(){ // make sure the image
                        $img.o3EnlargeBox({});                   
                    },1);
                });
        });
    });
    
  11. eaglejohn says:

    The code in my last post (thanks for editing it :-) ) works in my situation, but I guess it’s not a clean and efficient JS anymore. I just combined the original go.js and your suggestion.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>