smughack: bulk zoom thumbnail (super deluxe version)

devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
edited April 19, 2011 in SmugMug Support
[UPDATED March 14th, 2011]

With recent infrastructure updates, we have removed an endpoint the BZT depended on. Effective immediately current implementations will no longer work. We apologize for the last minute notice.

- SmugMug
David Parry
SmugMug API Developer
My Photos
«13456726

Comments

  • AndyAndy Registered Users Posts: 50,016 Major grins
    edited January 30, 2006
    clap.gif

    I got to alpha test this. Nice work, David. There are way MORE than a few folks on Dgrin who should be sending you nice thank-you boxes from Jack Stack's BarBQ Ribs deal.gif
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited January 30, 2006
    Thanks Andy :D
    David Parry
    SmugMug API Developer
    My Photos
  • Mike LaneMike Lane Registered Users Posts: 7,106 Major grins
    edited January 30, 2006
    kick ass...

    except....

    EEEK! Tables for layout. If I get a chance I'll see if I can't modify it a smidge thumb.gif
    Y'all don't want to hear me, you just want to dance.

    http://photos.mikelanestudios.com/
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited January 30, 2006
    Mike Lane wrote:
    kick ass...

    except....

    EEEK! Tables for layout. If I get a chance I'll see if I can't modify it a smidge thumb.gif

    thanks Mike.....well complain to smugmug, i hacked up their code :D

    No probs, modify it.....just post it so I can update the files.
    David Parry
    SmugMug API Developer
    My Photos
  • Gary GlassGary Glass Registered Users Posts: 744 Major grins
    edited January 30, 2006
    This looks great. But I'm not sure I understand how to implement it. Can you explain? Seems like a lot of JS to include on every page for a utility that is almost never used (but when it is you really want it bad!).
  • wellmanwellman Registered Users Posts: 961 Major grins
    edited January 30, 2006
    This is fantastic!!!! Thank you so much!
    clap.gif:Dclap.gif:Dclap.gifthumb.gif
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited January 30, 2006
    Gary Glass wrote:
    This looks great. But I'm not sure I understand how to implement it. Can you explain? Seems like a lot of JS to include on every page for a utility that is almost never used (but when it is you really want it bad!).

    sure Gary....


    css.txt contents -> CSS block
    javascript.txt contents -> Javascript block
    header.txt contents -> Header or Footer block

    The Javascript code has function that automatically loads ....


    addEvent(window, "load", addBulkThumbnail);

    addBulkThumbnail checks to see if you're loggedIn and on a Traditional gallery page, if not it does nothing.


    So basically there is nothing to implement, apart from adding the code.

    Hope this helps,

    David

    </pre>
    David Parry
    SmugMug API Developer
    My Photos
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited January 30, 2006
    wellman wrote:
    This is fantastic!!!! Thank you so much!
    clap.gif:Dclap.gif:Dclap.gifthumb.gif

    Thank-you Greg.

    I think it might have been your request for this feature that actually inspired me to write this.

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • bwgbwg Registered Users, Retired Mod Posts: 2,119 SmugMug Employee
    edited January 30, 2006
    Mike Lane wrote:
    kick ass...

    except....

    EEEK! Tables for layout. If I get a chance I'll see if I can't modify it a smidge thumb.gif

    you're so new age.

    i agree about tables for layout...but sometimes if it works....
    Pedal faster
  • MikeFriedMikeFried Registered Users Posts: 33 Big grins
    edited January 30, 2006
    Cool
    devbobo wrote:
    i have working on a new super deluxe version of my "bulk zoom thumbnail" hack.

    You know, I have only been a smugmug member for a little over a month, and I didn't even know about the zoom thumbnail feature.

    gerg.gif

    But I must say that your tool is neat. I'll have to try it on my site later on, and crop my thumbnails...

    ylsuper.gif

    For some reason, people on this site tend to use the most gratuitous emoticons...

    headscratch.gif
  • Gary GlassGary Glass Registered Users Posts: 744 Major grins
    edited January 31, 2006
    css.txt contents -> CSS block
    javascript.txt contents -> Javascript block
    header.txt contents -> Header or Footer block

    Thanks. I guess I didn't make myself clear though. What I mean is, even though it's a very clever tool, it's a tool that is of no use to anybody except the site owner, so dumping that much custom code into every page on the site just to implement a tool that is only used by one person and only rarely, makes no sense to me. Or am I missing something? I really, really, really think this should be implemented by SM.
  • Mike LaneMike Lane Registered Users Posts: 7,106 Major grins
    edited January 31, 2006
    bigwebguy wrote:
    i agree about tables for layout...but sometimes if it works....

    :nono :nah :puke
    Y'all don't want to hear me, you just want to dance.

    http://photos.mikelanestudios.com/
  • bwgbwg Registered Users, Retired Mod Posts: 2,119 SmugMug Employee
    edited January 31, 2006
    Mike Lane wrote:
    :nono :nah :puke

    allow me to re-phrase:
    if it works, and somebody else did all the work...
    Pedal faster
  • AndyAndy Registered Users Posts: 50,016 Major grins
    edited January 31, 2006
    Gary Glass wrote:
    Thanks. I guess I didn't make myself clear though. What I mean is, even though it's a very clever tool, it's a tool that is of no use to anybody except the site owner, so dumping that much custom code into every page on the site just to implement a tool that is only used by one person and only rarely, makes no sense to me. Or am I missing something? I really, really, really think this should be implemented by SM.

    But ... but...
    you can use it now :D
    and, it's FREE
    and you're not executing it on every page, are you? ne_nau.gif
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited January 31, 2006
    Gary Glass wrote:
    Thanks. I guess I didn't make myself clear though. What I mean is, even though it's a very clever tool, it's a tool that is of no use to anybody except the site owner, so dumping that much custom code into every page on the site just to implement a tool that is only used by one person and only rarely, makes no sense to me. Or am I missing something? I really, really, really think this should be implemented by SM.

    if ur that worried about some custom code being loaded, you could load the script file dynamically if required.
    David Parry
    SmugMug API Developer
    My Photos
  • Gary GlassGary Glass Registered Users Posts: 744 Major grins
    edited January 31, 2006
    I give up. This is so obviously a piece of functionality that SM should provide. The JS file alone is 19kb! I don't want to dump 19kb of JS onto my site for something that a user never even uses. I don't want to maintain bugfixes for it. I don't want to figure out how to load it dynamically. I want it to be part of the service I'm paying for. I don't think that seems like an unreasonable request.
  • AndyAndy Registered Users Posts: 50,016 Major grins
    edited January 31, 2006
    Gary Glass wrote:
    I give up. This is so obviously a piece of functionality that SM should provide. The JS file alone is 19kb! I don't want to dump 19kb of JS onto my site for something that a user never even uses. I don't want to maintain bugfixes for it. I don't want to figure out how to load it dynamically. I want it to be part of the service I'm paying for. I don't think that seems like an unreasonable request.

    Hi Gary. Ouch - I can see you are upset. Maybe step back a minute - and appreciate the value of the hacker community here that's come up with a pretty neat hack.

    JT and Onethumb have desires to have this tool in place in the SmugMug system, but there's no promise on if/when - so, why not enjoy the ride for a while? :D
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited January 31, 2006
    Gary Glass wrote:
    I give up. This is so obviously a piece of functionality that SM should provide. The JS file alone is 19kb! I don't want to dump 19kb of JS onto my site for something that a user never even uses. I don't want to maintain bugfixes for it. I don't want to figure out how to load it dynamically. I want it to be part of the service I'm paying for. I don't think that seems like an unreasonable request.

    Hey Dude,

    Listen... you obviously have a bee in your bonnet about this, take it up with support.

    I am not forcing you to use this hack, so take it or leave it...doesn't bother me.

    David
    David Parry
    SmugMug API Developer
    My Photos
  • Gary GlassGary Glass Registered Users Posts: 744 Major grins
    edited January 31, 2006
    For Pete's sake. This is not about whether or not Dave's tool is way cool. It certainly is a damn clever piece of work. I just don't think it is the best, or even an appropriate, solution to the mindnumbing tedium of zooming a gallery full of thumbnails.
    JT and Onethumb have desires to have this tool in place in the SmugMug system

    Excellent! I definitely second that emotion.
  • bwgbwg Registered Users, Retired Mod Posts: 2,119 SmugMug Employee
    edited February 2, 2006
    thanks Dave for this awesome hack...but waiting for the server response is SO SLOOOW!!

    So i got to thinking....why do we care what the server response is? Why cant we just fire off a bunch of requests to the server and let it do it's thing?

    A little trial and error and zoom zoom.

    By aborting the ajax request after it's sent to the server, we eliminate the need to wait for a response and can immediately submit another request. It effectively works the same as the bulk rotate function where it does all the work in the background while you do other things. Be aware though, that since we are aborting the query, we no longer have confirmation that the server recieved our request, so in that sense Dave's original is more reliable. That being said, i've processed over a thousand images with 100% success using this script as it exists now. There is a timer variable in the source that can be increased to allow the server a longer time to process before we abort.

    To use, just replace the original script with the attached.

    you will also need to add the following to your javascript section (sorry for the multiple things, but it's the only way around the attachment size limit).
    function isClass(sClass) {
    
      sClassName = document.body.className;
      re = new RegExp(sClass + "( |$)") 
    
      if (!sClassName)
        return false;
    
      return re.test(sClassName);
    }
    
    function wait(milliSeconds) {
        var now = new Date();
        var exitTime = now.getTime() + milliSeconds;
        while (true) {
            now = new Date();
            if (now.getTime() > exitTime)
                return;
        }
    }
    
    function ajax_abort(waitDuration, url, postArray, asText) {
        function ajax_create_xmlhttp() {
            var req = false;
            // branch for native XMLHttpRequest object
            if(window.XMLHttpRequest) {
                try {
                    req = new XMLHttpRequest();
                } catch(e) {
                    req = false;
                }
            // branch for IE/Windows ActiveX version
            } else if(window.ActiveXObject) {
                try {
                    req = new ActiveXObject("Msxml2.XMLHTTP");
                } catch(e) {
                    try {
                        req = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch(e) {
                        req = false;
                    }
                }
            }
            return req;
        }
    
        var req = ajax_create_xmlhttp();
        if (!req) { return false; }
        if(postArray) {
            req.open("POST",url,true);
            req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
            req.send(ajax_encode_array(postArray));
        }
        else {
            req.open('GET',url,true);
            req.send(null);
        }
            wait(waitDuration);
            req.abort();
    }
    
    Pedal faster
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited February 2, 2006
    Great work Lee.

    I could have sworn I saw a post of andy's in here headscratch.gif

    Gotta love this sharing.

    Someone needs to setup a smugmug hacker community :D

    David
    David Parry
    SmugMug API Developer
    My Photos
  • AndyAndy Registered Users Posts: 50,016 Major grins
    edited February 2, 2006
  • wellmanwellman Registered Users Posts: 961 Major grins
    edited February 2, 2006
    Andy wrote:

    Me neither. Maybe I haven't waited long enough? I re-thumbed about 80 photos about 10 minutes ago. Would 80 requests take that long to process? Could be, I suppose...
  • bwgbwg Registered Users, Retired Mod Posts: 2,119 SmugMug Employee
    edited February 2, 2006
    andy/greg either of you getting any errors in ffx javascript console?

    also, go into the code and turn the confirmation on, that will at least tell you if the code ran all the way through.
    Pedal faster
  • wellmanwellman Registered Users Posts: 961 Major grins
    edited February 2, 2006
    bigwebguy wrote:
    andy/greg either of you getting any errors in ffx javascript console?

    also, go into the code and turn the confirmation on, that will at least tell you if the code ran all the way through.

    I can't tell you anything about Firefox at the moment, as I'm at work and the man has his foot on the back of anyone desiring a browser other than IE. If the issue is still open, I'll be happy to check things out at home this evening.

    Sorry to be pretty much useless for the time being...
  • bwgbwg Registered Users, Retired Mod Posts: 2,119 SmugMug Employee
    edited February 2, 2006
    well, i'm an idiot.

    turns out that i'm apparently exploiting a firefox bug with the abort method.

    this wont work in anything other than firefox on windows.

    but it works great if you use ffx/win to do your site management!
    Pedal faster
  • AndyAndy Registered Users Posts: 50,016 Major grins
    edited February 2, 2006
  • wellmanwellman Registered Users Posts: 961 Major grins
    edited February 2, 2006
    Any chance the hack could be modified to work from the "all thumbs" gallery style? If I could batch an entire gallery and walk away, the wait would become a non-issue.

    devbobo, let me reiterate my thanks for the great work. BWG, think of your revision as making use of a feature. :D
  • bwgbwg Registered Users, Retired Mod Posts: 2,119 SmugMug Employee
    edited February 2, 2006
    bigwebguy wrote:
    well, i'm an idiot.

    ok, attempt #2. the abort method and i ended up not working out, so we're on a break.

    the thing that slows down the original hack is that it waits for one request to finish before sending another one. This version sends all the requests at once (more or less) and then handles the responses as they come back in. I was able to cut the processing time in half with this change.

    the bottleneck however, is that browsers are limited to a specified number of connections at any given time. For example, firefox is set to 2 concurrent connections per server. that means if we have 16 thumbnails to process, we can only do 2 at a time.

    check out these links on how to modify these settings.
    firefox
    IE

    using those settings, i was able to cut the processing time by another 60% because we can send all the requests at once.

    original: approx 2min for 16 thumbnails
    modified: ~1min
    browser settings: ~20sec

    note: used to be that messing with those settings could cause issues w/older web servers and proxy servers....i personally dont notice any problems.

    save the attached file and copy the guts into your javascript block. use devbobo's original css and html.
    Pedal faster
  • bwgbwg Registered Users, Retired Mod Posts: 2,119 SmugMug Employee
    edited February 2, 2006
    oh, it's been tested on FFX 1.5 and IE6 on winxp

    any mac ppl care to chime in?
    Pedal faster
This discussion has been closed.