PDA

View Full Version : Adding custom size link to footer


mchasal
Feb-22-2009, 01:59 PM
Hi all,

Through searching and reading here, I've managed to get a couple of lines of Javascript together that create a link to a custom sized image (480 wide) that I need to make available. Here's a gallery that shows it:
http://chasal.smugmug.com/gallery/7405059_fG2Xe/1/477082343_z8JVA#477082343_z8JVA
Down at the bottom there is a link, "Blog Image..." that will point to the appropriate size image. The problem I'm having is that in the SmugMug style, that link always points to the first image and not the one that is displayed. It works fine in Traditional, and I'll just use that if I need to, but the SmugMug style is much nicer.
Is there a, not terribly complicated, way to get it to update on image load, perhaps by embedding it up where the "Keywords" are?

Here's the Javascript I have now:

ImageUrl = webServer + "/photos/" + ImageID + "_" + ImageKey;
document.write('<center><a href='+ImageUrl+'-480x10000.jpg>Blog image(480 wide)</a></center>');


Thanks for any help.

jfriend
Feb-22-2009, 05:05 PM
Hi all,

Through searching and reading here, I've managed to get a couple of lines of Javascript together that create a link to a custom sized image (480 wide) that I need to make available. Here's a gallery that shows it:
http://chasal.smugmug.com/gallery/7405059_fG2Xe/1/477082343_z8JVA#477082343_z8JVA
Down at the bottom there is a link, "Blog Image..." that will point to the appropriate size image. The problem I'm having is that in the SmugMug style, that link always points to the first image and not the one that is displayed. It works fine in Traditional, and I'll just use that if I need to, but the SmugMug style is much nicer.
Is there a, not terribly complicated, way to get it to update on image load, perhaps by embedding it up where the "Keywords" are?

Here's the Javascript I have now:

ImageUrl = webServer + "/photos/" + ImageID + "_" + ImageKey;
document.write('<center><a href='+ImageUrl+'-480x10000.jpg>Blog image(480 wide)</a></center>');

Thanks for any help.

That is because you are generating the link and the URL in the link at the time the page is loaded and the first image is the selected image at that time. Your code never changes even though another image becomes the selected image, thus the link always goes the same place. You need to make your link call a javascript function that generates the URL at the time of the click (using the same code logic you already have) and then goes to it.

mchasal
Feb-23-2009, 01:51 PM
Thanks for the reply. I'll work on that approach.