Results 1 to 10 of 10

Thread: get size on image

  1. #1
    Join Date
    Feb 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question get size on image

    1) Script Title:
    LightBox

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...box2/index.htm

    3) Describe problem:
    I'd like to print the image width and height in the title of the image.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Print? I hope you don't mean for the printer only. Anyways, if not, just search in lightbox.js for the line that begins like this:

    Code:
    Element.setInnerHTML( 'caption'
    there's only one, change that whole line to:

    Code:
    Element.setInnerHTML( 'caption', imageArray[activeImage][1]+' ('+imgPreloader.width+' x '+imgPreloader.height+')');
    Make sure to include a title attribute with each rel="lightbox" link on your page, it can even be:

    Code:
    title=" "
    if you want.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    Print? I hope you don't mean for the printer only. Anyways, if not, just search in lightbox.js for the line that begins like this:

    Code:
    Element.setInnerHTML( 'caption'
    there's only one, change that whole line to:

    Code:
    Element.setInnerHTML( 'caption', imageArray[activeImage][1]+' ('+imgPreloader.width+' x '+imgPreloader.height+')');
    Make sure to include a title attribute with each rel="lightbox" link on your page, it can even be:

    Code:
    title=" "
    if you want.
    Doesn't seem to work.
    I didn't put the code where you said though... The thing is that I've rewriten the code where the link is.

    Code:
     
    return ddimageTitleFinal=(ddimageTitleURL!=null && ddimageTitleURL!="")? '<a href="#" OnClick="MyWindow=window.open(\''+ddimageTitleURL+'\',\'Window\',\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=600\'); return false;">'+ddimageTitle+'</a>'
    This is where I'd like the wiidth and height to be a bit larger than the image.
    So what can I write instead of: width=500,height=600\' ?

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, you should put it right where I suggested. However, your modification:

    Code:
    return ddimageTitleFinal=(ddimageTitleURL!=null && ddimageTitleURL!="")? '<a href="#" OnClick="MyWindow=window.open(\''+ddimageTitleURL+'\',\'Window\',\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=600\'); return false;">'+ddimageTitle+'</a>'
    is flawed. It should be:

    Code:
    return ddimageTitleFinal=(ddimageTitleURL!=null && ddimageTitleURL!="")? '<a href="#" onclick="MyWindow=window.open(\''+ddimageTitleURL+'\',\'Window\',\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=600\'); return false;">'+ddimageTitle+'</a>' : ddimageTitle;
    So that the entire DD added function now looks like so:

    Code:
    function getImageTitle(anchor){ //DynamicDrive.com added function that allows the caption("title") to be linked ("rev").
    	var ddimageTitle=anchor.getAttribute('title')
    	var ddimageTitleURL=(ddimageTitle!=null && ddimageTitle!="")? anchor.getAttribute('rev') : null
    	return ddimageTitleFinal=(ddimageTitleURL!=null && ddimageTitleURL!="")? '<a href="#" onclick="MyWindow=window.open(\''+ddimageTitleURL+'\',\'Window\',\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=600\'); return false;">'+ddimageTitle+'</a>' : ddimageTitle;
    };
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Feb 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    Well, you should put it right where I suggested. However, your modification:



    is flawed. It should be:

    Code:
    return ddimageTitleFinal=(ddimageTitleURL!=null && ddimageTitleURL!="")? '<a href="#" onclick="MyWindow=window.open(\''+ddimageTitleURL+'\',\'Window\',\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=600\'); return false;">'+ddimageTitle+'</a>' : ddimageTitle;
    So that the entire DD added function now looks like so:

    Code:
    function getImageTitle(anchor){ //DynamicDrive.com added function that allows the caption("title") to be linked ("rev").
    	var ddimageTitle=anchor.getAttribute('title')
    	var ddimageTitleURL=(ddimageTitle!=null && ddimageTitle!="")? anchor.getAttribute('rev') : null
    	return ddimageTitleFinal=(ddimageTitleURL!=null && ddimageTitleURL!="")? '<a href="#" onclick="MyWindow=window.open(\''+ddimageTitleURL+'\',\'Window\',\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=600\'); return false;">'+ddimageTitle+'</a>' : ddimageTitle;
    };
    It's right. I just didn't write that entire code...

    But still... The window size... I'd like the window size to be set dependign on picture size.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by ketels View Post
    But still... The window size... I'd like the window size to be set dependign on picture size.
    Still? First I've heard of it. I'll have to get back to you on that.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    OK, now let's see. After the lightbox displays the image, you want the user to be able to click on the caption in the lightbox and have it pop up a window with the same image in it with that window tailored to the dimensions of that image? Why?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Feb 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    OK, now let's see. After the lightbox displays the image, you want the user to be able to click on the caption in the lightbox and have it pop up a window with the same image in it with that window tailored to the dimensions of that image? Why?
    The reason is.. well simple.
    I hae a galery. You can view all photos but you can also click the "buy" button.
    Here you'll see the shoosen picture and a number of options for buying the photo.

    Therefore I have the popup-script and therefore I want to use the picture size (plus a fiew pixels).
    To use it to resize my popup window.

    Do you think it's "do-able"?

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Yeah, I get it now. You cannot use imgPreloader.width/height in the getImageTitle function because they're not available yet, but you can use tokens in the string created by the getImageTitle function later in the line I was talking about to replace them with the imgPreloader.width/height values which will be available at that point. As it currently stands, if you are using this getImageTitle function:

    Code:
    function getImageTitle(anchor){ //DynamicDrive.com added function that allows the caption("title") to be linked ("rev").
    	var ddimageTitle=anchor.getAttribute('title')
    	var ddimageTitleURL=(ddimageTitle!=null && ddimageTitle!="")? anchor.getAttribute('rev') : null
    	return ddimageTitleFinal=(ddimageTitleURL!=null && ddimageTitleURL!="")? '<a href="#" onclick="MyWindow=window.open(\''+ddimageTitleURL+'\',\'Window\',\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=600\'); return false;">'+ddimageTitle+'</a>' : ddimageTitle;
    };
    You can use the 500 and the 600 as the tokens, and have this at the Element.setInnerHTML( 'caption' line, like so:

    Code:
    Element.setInnerHTML( 'caption', imageArray[activeImage][1].replace(/500/, imgPreloader.width+20).replace(/600/, imgPreloader.height+50));
    to replace those tokens with the values now available plus whatever you like (in the above I add 20 to the width and 50 to the height).
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. #10
    Join Date
    Feb 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I really don't know what to say... You are my savier...
    THANK YOU!!!!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •