maxImage: jQuery image scaler

maximage screen shot

maxImage is a jquery plugin that I wrote a few months ago that automatically scales images based on how much room they have in the browser window. The image will always fill your browser window. I have built a basic demo mini site for the plugin.

Note: For some reason I have lost the post that originally contained the release of my plugin. I would like a place for users of the plugin to contact me and let me know how use of the plugin is going. Please use this space, the comment area to let me know how using maxImage is going, what you would like to see added or changed.

69 Responses to “maxImage: jQuery image scaler”

  1. Aaron Fineman Says:

    This is a great script, but I was wondering if there is a way to have the image stay in the center of the site and scale by top and bottom or left and right sides? – does that question make sense?
    Or if it is possible to manually control the slideshow that would be great too – like a giant gallery.
    thanks,
    aaron

  2. DAvid Says:

    Hello Aaron,

    Great script ! Thx a lot !
    I’ve got just one issue on Firefox (3.5) on Mac OS X when pushing the Space bar : the image goes down like if there was a scroller…

    Sorry, my english is too bad :/

    ++

    DAvid

  3. Aaron Vanderzwan Says:

    Thanks David… I will look into this.

  4. Aaron Vanderzwan Says:

    @Aaron. Thanks for the feedback. Unfortunately maxImage does not support your scenario right now. I apologize, but will keep it in mind as I work towards future releases. Thanks.

  5. DAvid Says:

    Thanks Aaron, it’s just a minor issue… i can reduce it to the max with topSpace attribute in my case…
    I will give you the adress of the site where I’m using your script when it’s ready :)

    ++

    DAvid

  6. Jesper Ordrup Says:

    Super script. I found the same issue as DAvid.

    I’m planning on using the slideshow effect on background images. Is it possible to start with random? Or specify starting image (then I’ll just feed it a random number)?

    Thanks
    Jesper

  7. Jaume Bosch Says:

    Hi, all.

    The script is working perfect with major browsers but i found that it doesn’t work in Firefox 2.

    Is there any chance to making it wokr in that browser?

    Sory about my english and thanks.

  8. Aaron Vanderzwan Says:

    @Jesper. I apologize but currently the script does not have the ability to start on a random image or specify a starting image. It does however, start with the first image every time. You can use this to your advantage and randomize the order on load, before calling the plugin, which would result in the same effect. Hope that helps.

  9. Aaron Vanderzwan Says:

    @Jaume. Hi there. Do you have an example that I can check out where it is not working in Firefox 2? That would be a great help. Thanks.

  10. Jesper Says:

    Thanks Aaron. That’s doable for sure. I just wanted to be sure that U didn’t provide this feature bfore doing it myself

    thanks
    jesper

  11. Rutger Says:

    Grrreat! Thanks for this amazing plugin!

    Maybe a fade option for the slideshow? Nevertheless, i just love it!

  12. Rutger Says:

    Spend some time but due to your plugin i’ve redesigned my homepage completely. http://www.heijmerikx.com/

    Thanks again!

  13. Woody24 Says:

    After some fighting, I’ve finally figured out how to get this to work in Wordpress. It also doesn’t help that I’m not that well educated about javascript, or PHP.

    But my question is, is it possible to have a scrolling page, with the image still stuck in place? I have some pages the go longer than the ‘fold’, but now that I’ve added this plugin, the scroll bars are gone. I guess I just figured that the background wouldn’t move when scrolled.

  14. Woody24 Says:

    oh, another question. How does the “verticalAlign: ‘bottom’” code work? I’ve changed it to both top and bottom, and didn’t notice a difference. I have a photo that is taller than the window, and I’d like for the bottom of the photo to start at the bottom of the window, and all the eccess of the photo goes past the top of the window.

    Thanks

  15. Aaron Vanderzwan Says:

    @Woody24 and all others who have asked about verticalAlign. I have fixed the bug that was not allowing the verticalAlign to work correctly on the slideshows. Please take a look at the new release and let me know if it works well for you. I do warn you though there are a few other updates too, so don’t push live without testing first.
    Download the newest release here: http://plugins.jquery.com/project/maximage

    I apologize but currently the overflow is set to hidden. I am looking into this for the next release.

  16. Rutger Says:

    How can i pause the slideshow on the background? Or isn’t that possible? Thanks in advanced for any reply.

  17. Aaron Vanderzwan Says:

    Rutger -

    Your website is amazing and powerful. A great usage of maximage. Do you mind if I use your website as an example of how maximage can be used to make powerful, dynamic websites?

    My only suggestion, would be to do what you can to make your large background images are less than 500k. One of them (ijsselpath.jpg) looked like it was over 1.6MB. But other than that, what a wonderful site. You are a WONDERFUL photographer!

    Unfortunately, right now, I do not have any way to pause the slideshow. I will think about this with future releases though.

    What a great website.

  18. Mael Says:

    Hi
    I tried something to simulate the window scrollbar :
    I made a parent div “#viewport” with “overflow:auto” andthen I fixed its height to the document’s one :

    var myheight = $(window).height();
    $(‘#viewport’).height(myheight);

    It actually display the scrollbar as excepted when the document exceed the window size, but if I resize my browser “#viewport” will keep the same heigt. The page should be refreshed when resized.

    I think it’s a good start to fix the overflow issue. If you have an idea for refreshing at resizing…

  19. Mael Says:

    This works :

    CSS:
    #viewport {overflow: auto; position: relative;}
    The div #viewport is the direct child of body.
    JS :
    var myheight = $(window).height();
    $(‘#viewport’).height(myheight);
    $(window).resize(function () {
    $(“#viewport”).height(document.documentElement.clientHeight);
    });

    I tested it in FF3, ie6 7 & 8, Safari 4
    I once had an error in ie7 but could’nt reproduce it…

  20. Aaron Vanderzwan Says:

    Solution to the scrollbar problem

    Hey Mael and all others who are trying to use maxImage and preserve the use of the overflow hidden attribute. I appreciate your initiative to get this to work the way you need to. That is needed with these plugins. It is impossible to create a tool that does everything for everybody.

    That being said, the reason why I disabled the scrollbar was because I was noticing that some browsers would calculate the width of the browser differently and therefore would make maximage a little inconsistent at times.

    I have just released a version with an “overflow” option that can be set to auto to re-enable the scrollbars [Download it here]. If you are using maxImage for it’s background image or background slideshow functionality, you can use position:fixed on the image so that the image doesn’t scroll.

    See an example here:
    http://www.aaronvanderzwan.com/maximage/bg.php

    I hope that helps. Also, Mael, your solution seems wonderful and definitely should work. Maybe a little more complicated than it needs to be at this point. If we notice that my solution is just too darn buggy (I’m nodding in your direction IE), your solution might be a good fallback… if you don’t mind me using it.

    Enjoy all. And let me know how this update works. Do you notice any problems?

  21. Thiago Azurem Says:

    :) This script do not accept fadeIn opacity configuration, I tried to use FadeTo but dont works.

  22. Aaron Vanderzwan Says:

    I’m sorry Thiago, the plugin is not built to support fadeTo.

  23. Mael Says:

    I’m glad to help !
    I won’t test the new release now because I use the older on a soon-online site, but I will give you feedback if I find any problem in a future use.
    Thanks again for sharing this !

  24. elgin Says:

    Hi again Aaron,

    Please disregard the previous email from me. Duh? I’ve got everything working now.

    Thanks,

    elgin

  25. Helder Says:

    Your plugin works great for me but only one question:
    Is there a nice work around for aborting the slideshow en playing the slideshow?

  26. Richard Bakker Says:

    Hi Aaron, this plugin is cool.
    I was wondering, would it be possible to put an image centered on a page with a padding lets say 20px and let it scale/resize on browser-resize ? Thus, something like the fullscreen/background solution, but not let it fill out all the way.

  27. Aaron Vanderzwan Says:

    @Richard Bakker
    This should be possible. It gets a little more complicated when you want to use the offsets. Do you have a URL that I can see? I might be able to help point you in the right direction.

    Thanks.

  28. Jerry Liu Says:

    Thank you for your Great Job!
    Can you make a more detail document? thanks.

  29. Aaron Vanderzwan Says:

    @Jerry Liu
    I have been meaning to do this, but I just can’t seem to find time. Is there anything you are having trouble with?

  30. Dennis Says:

    Hey,

    great script! But i have one question. When i have a resolution of 1024 x 768. The background on end of the page will cut off the background. Can you handle it?

    Please awnser on my E-Mail-adress.

    Greetings
    Dennis

  31. Aaron Vanderzwan Says:

    Dennis -

    I have sent you an email.

  32. Theo Ribeiro Says:

    Hi Aeron,

    First of all, thanks for the great job, this plugin is a great implementation!

    I have a special need I believe many people may have. I would like to ask you if it’s possible, or if you have ever done it (I have a very limited jQuery knowledge as I’m a photographer not a web-designer).

    I’m trying to use the Plugin with images contained in a div that already resizes with the browser window but the images should not exceed the div boundaries as they do using maximage.
    What I need is to set max-width and max-height of the image to 100% (so it doesn’t exceed div size).

    I want to have a fluid layout, otherwise I could use the offset properties, etc but they just wont do…

    If I do this through CSS, it works as long as the user reloads the page after resizing but it doesn’t quite work dynamically as it should.

    Have you though of this or could you give-me a hand with this?

    Thanks loads in advanced and again, congratulations and thanks for putting up maximage!

    Theo

  33. Aaron Vanderzwan Says:

    Hi Theo-

    Do you have a URL that you can share so that I can check out what you are trying to do? That would help a lot.

    Thanks,
    Aaron

  34. Vince Says:

    Hi Aaron,

    first of all, congratz for the terrific work done with this plugin. Simply amazing !!!

    Do you know if there are conflicts between your plugin and the Galleria plugin (http://devkick.com/lab/galleria/) ?

    I am trying to use both at the same time with no success …

    Thanks. Vince

  35. Aaron Vanderzwan Says:

    Hi there Vince.

    I do not know if there are any problems with using maxImage and Galleria. I have actually never used it. It looks good though and might have to look at it sometime.

    Let me know if you have any success. And if there is a URL where you are looking at it so I can check it out.

    Thanks.

  36. daniel Says:

    hi, great plugin, but what’s happening if i have more then one image on page?
    is there any way to handle multi img resize.

    Tnx, Daniel

  37. Aaron Vanderzwan Says:

    @daniel

    I have not tested the plugin for more than one image on a page. However, I have built another plugin, called maxgrid, that resizes images so that they fit to a grid.

  38. Terio Says:

    Hi

    Thanks for a great script, it is currently in use by one of our customers. We plan on using it on more sites, so I hope that you will continue maintaining it? Or that older versions will continue to work as they are – I suppose that is the case…

    WIll be back with links later on!

  39. Richard Bakker Says:

    Hi Aaron, i’m back again :’)
    I am trying something else, what if I want to have to 2 images next to each other – can this work somehow ? (I have more portraitshots than landscape)

  40. Aaron Vanderzwan Says:

    Hi Richard -

    I’m sorry, but currently the plugin does not handle that. It would have to be reprogrammed for multiple images. Please take a look at maxGrid though (http://www.aaronvanderzwan.com/maxgrid/). I have not tested this, but it might work with just two images in that plugin. maxGrid is not an official release so please test A LOT before going live with it.

    Let me know how it goes.

  41. Syrehn Says:

    is it possible to have this contained inside a div instead of setting the vertical and horizontal offset.

  42. Syrehn Says:

    I believe my question is something similar to Theo’s.

  43. Aaron Vanderzwan Says:

    Hi Syrehn –

    Like I requested with Theo, can you please send me a URL where I can see the issue you are having and what you are trying to accomplish. That would help a lot.

    Thanks,
    Aaron

  44. Syrehn Says:

    Hi Aaron,

    I’m trying to accomplish something what I have done here:

    http://www.designfoxmediaworks.com/clients/peaverymart/

    I have managed to get my image to resize because I know the width that the containing div is when fully expanded and have it set to scale down to 30%. (this is done without yourscript)

    I wanted to use your script to accomplish the same thing but have it as a background image in the div perhaps so that I could have functioning links above the image.

    I hope that made sense?

  45. Syrehn Says:

    any thoughts?

  46. Aaron Vanderzwan Says:

    Hi Syrehn-

    I’m sorry if i just got to your comment to late (this is a little over a week after you posted your URL), but the link that you posted is not working. I am getting a 404.

    Please post again with a different working URL.

    Thanks,
    Aaron

  47. Rutger Heijmerikx Says:

    Hi Aaron!

    I’m sorry to say that i just saw your reply on my comment. Of course you may use my site as an example. I’m planning on optimizing it indeed. An image above 1Mb is a bit large.

    Greets and thanks for your superb plugin!

  48. AK Says:

    Hi,

    Just using your plugin and most is working well. Thanks! I just need to know if you can fix the problem with resizing the first image on each slideshow. The first image in each slideshow doesn’t scale and is fitted to the size of the browser you start with. I checked your example and it did exactly the same thing. If you could help me with this that would be great!

    Thanks,
    AK

  49. Matt Johnson Says:

    Is there any way to control the slide show? Next/Previous buttons.

  50. lingjaidee Says:

    script slide bg is very interesting for me ;)
    nice script & thx for inspiration

    from THAILAND

  51. Murat OVA Says:

    Where Parameter For Fade Speed ?

  52. edward Says:

    hi aaron. great plugin. works beautifully on all browsers i’ve tested on, except for Firefox 2 on PC. it shows only the background color. thoughts? i was racking my brain on this, but i also checked your example site (http://www.aaronvanderzwan.com/maximage/) and your site doesn’t display the image either.

    here’s my example: http://eddieshrake.com/AP

    thanks much

  53. Aron Says:

    Hello!

    Hello, when i try to implement your script for the dynamically scaling background image, i get vertical and horizontal scrollbars.

    does the base image have to be a specific size? no matter how i resize the windows, the scrollbars stay ….

    greetings Aron

  54. IK Says:

    Hi AK,

    I got the same problem as you where the first image of the slideshow didn’t want to resize, i had a look at the “jquery.maximage.js” file and altered the following to get it to work:

    Approx. line 201, under //SLIDESHOW FUNCTIONS:

    change this bit from:

    if(currentImage==0){
    _start_timer();
    }

    to:

    if(currentImage==1){
    _start_timer();
    }

    Approx. line 214:

    change this bit from:

    function _start_timer() {
    var currentSlide = 0;

    to:

    function _start_timer() {
    var currentSlide = 1;

    Approx. line 236, under // Start time for slideshow :

    change this bit from:

    var slideInterval = setInterval(function(){
    if(currentSlide < opts.imageArray.length-1){
    currentSlide++;
    lastSlide = currentSlide-1;
    } else {
    currentSlide=0;
    lastSlide = opts.imageArray.length-1;
    }

    to:

    var slideInterval = setInterval(function(){
    if(currentSlide < opts.imageArray.length-1){
    currentSlide++;
    lastSlide = currentSlide-1;
    } else {
    currentSlide=1;
    lastSlide = opts.imageArray.length-1;
    }

    I don't know any Javascript though what it seems to do is make it start from the second image, so that means you will need to add a blank placeholder image to the list of images so it recognises this as the first image and therefore will be skipped.

  55. Aaron Vanderzwan Says:

    @AK, and IK
    What browser are you working in where you are having this problem. This is not a problem in all of the browsers that I am viewing it in (I’m on a mac).

    @Matt Johnson
    Unfortunately I do not have any way to control the slideshow with Next/Previous buttons yet, but will keep this in mind when I find time for the next update.

    @Murat Ova
    The parameter for fade speed is slideDelay.

    @Edward
    Your website looks beautiful. I am currently downloading Firefox 2. I will pull it up and give it a look. Hopefully I will be able to see something that will resolve your issue. Is Firefox 2 a large market share for users?

    @Aron
    I would check your other CSS. By default, maxImage hides the scrollbars with overflow:hidden. You can control the overflow-y with the ‘overflow’ parameter. But like I said, it defaults to hidden. Make sure you don’t have any other styles controlling this. Do you have an example I can look at?

    @IK
    I thank you for your fix, but would really like to fix this issue without having to put a blank image in the first space. Could you let me know what browser, what platform, how many images, the size of images, and any other information you think could help. I would really appreciate it. It sounds like it has something to do with load time or order and when I check the dimensions of the images. Thanks again for your interest in helping this issue get resolved.

    @ALL
    Thanks for the positive feedback. I am sorry I have been so busy lately, but I look forward to upgrading maxImage to take advantage of the speed upgrades in jQuery 1.4. Keep the comments coming, I want to help get this thing working as smoothly as possible.

    Thanks again.

  56. Bjarne // Mums Studio Says:

    Hey Aaron!

    First, thanks! This is by far my preferred way to make websites with fullscreen BGs. One thing I miss though – haven’t digged into this myself yet – is slideshow with navigation. Perhaps just simple next / prev or even numbered navigation.

    Just an input!

  57. IK Says:

    Hi Aaron,

    Yes, that blank image thing i did was pretty nasty, the site i’ve been working on uses 5 images, all at 1080×810px, thing is i get the same thing happening on the slideshow page on your site as well (http://www.aaronvanderzwan.com/maximage/bgslideshow.php).

    So far i’ve tried this on Safari 4 / Firefox 3.5 on Mac OS 10.5.8 and IE6 / IE8 on XP SP3, all with the same result, when you resize the browser the first image stays the same size and seems to pin itself to the bottom left corner of the browser window.

    Hope that helps!

  58. Boyce Hedeen Says:

    Great blog, although I think some of the stuff on itt is a little pre used lol.

  59. tinkdiff Says:

    dear Sir,

    please have a look to this website:

    http://ayerviernes.com/

    can this plugin to have an easing effect when the browser resized just like that website ?
    it would be cool if you have a navigation for the image slide

    please advise

  60. Kai van Lingen Says:

    Hi there,

    First things first, thanks for this great plugin.

    I was wondering if there is any way to center the image vertically?

    Your help would be great.

  61. steven yeung Says:

    HI Aaron,

    I am using your plugin and I am trying to build a simple website.
    What I am finding when you your plugin is that when I am stretching the browser window, image rescales no vertical scrollbar appears but a horizontal one does.

    Is there something I am doing wrong.

    I am testing it on safari 4.0 and firefox 3.5

    When looking at your site no scroll bars appear at all.

    Please can you help me.

    Thanks

  62. Reo Says:

    Because sentences are made with a translation software, it might be strange.

    HI Aaron,

    First of all, we wish to express our gratitude for making the good one.

    It is IE6 correspondence, and the demo page has been generated, too. The background image has fallen below.

    The background image falls into the page that I made below in IE6.
    http://www.harusa-web.com

    Is there a problem in a Japanese version of IE6?

  63. Reo Says:

    I’m sorry.
    It changed it into another plug-in.
    Moreover, it uses it on another page.
    Thank you.

  64. Chris Says:

    Hey Aaron.
    I’m trying to use this plugin with a centered div (ie. margn: 0px auto;) and it doesn’t keep the image centered but to the right of the div when it resizes, any idea to keep it exactly centered in the browser window no matter what?
    On top of that I’m trying to use it JQuery Cycle Plugin and it works on the initial image, but none of the others.
    Thanks again for making this, if I can get it to work how i need it, its exactly what i needed!

  65. gnarwrangler Says:

    Chiming in to say that I finally found the issue causing the first slide in the slideshow to not resize properly.
    Change the section ~line 217 from:

    if(currentImage < opts.imageArray.length-1){
    currentImage++;
    _loads_image(currentImage);
    }

    To:

    if(currentImage < opts.imageArray.length-1){
    _loads_image(currentImage+1);
    }

    This should fix it.

  66. Jean-Marc Says:

    Hi

    Great job, thank’s a lot !

    I try it, but i have a problem : how to diseabled Title in a slideshow (the title which is back right) ?

    Have a good day

    JM

  67. bHab Says:

    The script is great but I am also having the problem with the first slide not resizing, this is happening on your sample page as well for me. I tried the fix from gnarwrangler but it didn’t work for me, and removed the 2nd slide out of 3 from the rotation.

    These are the browsers I have tested:

    Mac

    FF 3.5.8
    Safari 4.0.4
    Chrome 5.0.307.11 beta

    PC

    IE 7.0.6001.18000
    IE 8.0.6001.18702
    Firefox 3.0.16
    Safari 3.2.3

    Thanks again.

  68. Jon Says:

    I’m with Bjarne — Any way to make the slideshow usable with a Next/Prev type function?

Leave a Reply

Note: Since I upgraded to Wordpress 2.7, I have been able to support adding code to comments. If anyone knows of a plugin (that has been tested in 2.7) that will do this, please let me know. Other basic HTML is allowed for styling.