Random Image Code Results in Unwanted Redirect
TnHiker
Registered Users Posts: 29 Big grins
I'm a novice HTML programmer who often links to my SmugMug photos from a 100+ page website I operate as a hobby. Recently I inserted a bit of code gleaned from these pages to generate a random image. Everythilng works great except that when I click on the image I get redirected to the smugmug.com instead of my linked gallery. The URL generated by the click starts off as intended but before the display loads it redirects to the smugmug.com homepage. Here is the code I'm using (remove the *'s):
<*div class="right_image"><a href="*http*:*//tnhiker.smugmug.com/gallery/4473102" *target="_new"><*img src=*http*:*//tnhiker.smugmug.com/photos/random.mg?AlbumID=4473102&AlbumKey=dyamC&Size=250x200*img style="float: right;" *alt="Right Image" /><*/a></div>
Here is the link to the code I've customized: http://wiki.smugmug.com/display/SmugMug/Random+Photos+Code
I'd like to either have the action upon clicking to be a new window that loads the gallery indicated by my albumID, OR, I'd like no action at all (no new window, no redirect). Help please. Note that I'm a "standard account level" user.
<*div class="right_image"><a href="*http*:*//tnhiker.smugmug.com/gallery/4473102" *target="_new"><*img src=*http*:*//tnhiker.smugmug.com/photos/random.mg?AlbumID=4473102&AlbumKey=dyamC&Size=250x200*img style="float: right;" *alt="Right Image" /><*/a></div>
Here is the link to the code I've customized: http://wiki.smugmug.com/display/SmugMug/Random+Photos+Code
I'd like to either have the action upon clicking to be a new window that loads the gallery indicated by my albumID, OR, I'd like no action at all (no new window, no redirect). Help please. Note that I'm a "standard account level" user.
Things are looking up. :thumb "Today is the first day of the rest of your life."
Click for Hike Journal website.
SmugMug acct: http://tnhiker.smugmug.com/
Click for Hike Journal website.
SmugMug acct: http://tnhiker.smugmug.com/
0
Comments
I use the random image generation all of the time. Here's an example of some code I used on this blog page - http://denisegoldberg.blogspot.com/2007/11/visions-of-death-valley.html:
Musings & ramblings at https://denisegoldberg.blogspot.com
In order to show a photo plus have a click send the viewer into your album, you'll need to use a combination of <A href= and <img src=" statements.
Here's an example (remove the *'s):
<*a href="/gallery/3961344" title="Snow!? Winter 2007 to 2008" alt="Snow!? Winter 2007 to 2008">
<*img src="/photos/random.mg?AlbumID=3961344&Size=300x300"></*a>
Can you paste in the code you are using? Make sure to include *s within the code so that the forum software doesn't swallow the url.
--- Denise
Musings & ramblings at https://denisegoldberg.blogspot.com
Thanks Denise. I used a version of your code for my website and it produced the results I'd wanted. Here is the code I ended-up using:
<*img src=http://tnhiker.smugmug.com/photos/random.mg?AlbumID=4473102&AlbumKey=dyamC&Size=300x240 img style="float: right;">
Also, thanks for the supplemental post about linking to image galleries when clicking the image. I'll incorporate that technique a bit later today.
Great advice!
Click for Hike Journal website.
SmugMug acct: http://tnhiker.smugmug.com/
You are linking to: http://tnhiker.smugmug.com/gallery/4473102
There is no gallery with ID 4473102 on Smugmug, hense it redirects to the Smugmug home page when it can't find it.
Browse to the gallery you want to link to, then copy the complete URL. I suspect you are just missing the end of the URL which would include an underscore and some more characters.
Yeah, http://tnhiker.smugmug.com/gallery/4473102_dyamC is the full link to the gallery.
Thanks for the on-target reply. I was leaving-off the album key.
Click for Hike Journal website.
SmugMug acct: http://tnhiker.smugmug.com/
Thanks for your help. I was leaving off the album key on this "new" album.
Click for Hike Journal website.
SmugMug acct: http://tnhiker.smugmug.com/
I've just used your code-example and it works just great thx.
Code:
document.write('<*img src=http://tnhiker.smugmug.com/photos/random.mg?AlbumID=4473102&AlbumKey=dyamC&Size=150x150 border=0></a>');
BUT if I copy-paste your code example and edit for my site then it doesn't work anymore. <img src="https://us.v-cdn.net/6029383/emoji/headscratch.gif" border="0" alt="" >
Link: http://nextrategy.smugmug.com/gallery/*4336820_N7KQT
document.write('<*img src=http://nextrategy.smugmug.com/photos/random.mg?AlbumID=4336820&AlbumKey=N7KQT&Size=150x150 border=0></a>');
Can you tell me how I can fix this?!
Thx and greets from the Netherlands.