 |

glennp
Novice
Mar 5, 2008, 1:56 PM
Post #1 of 6
(1300 views)
Shortcut
|
|
Image Hardcoding
|
Can't Post
|
|
I've got an image hardcoded on the home page template (src="$homepage_url$/images/$user_num$_1.jpg"). It works fine as long as the user doesn't change their images around. If they happen to delete the image that was assigned "_1.jpg", then obviously the link is broken. Any suggestions to work around this? Thanks! Glenn
|
|
|  |
 |

MikeB
Staff
/ Moderator

Mar 5, 2008, 4:25 PM
Post #2 of 6
(1291 views)
Shortcut
|
Hi Glenn, Thanks for the post! I've had a look at this for you and I'm a bit curious as to what you were looking at setting up here with this hardcoded image. Any other details you could provide about this would be great. There may be a way you can get around this with some JavaScript error checking on the name of the image to try _2.jpg or_3.jpg instead. That said, there may be a better way depending on what you're hoping to set up so any other details you have would be helpful. I look forward to hearing from you Glenn! Cheers, Mike Briggs - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 |

glennp
Novice
Mar 5, 2008, 5:19 PM
Post #3 of 6
(1289 views)
Shortcut
|
Hi Mike, I'm using the hardcoded image is because of the layout on the page. I'm using tabbed browsing - one of the tabs has a single image (the hardcoded one) and another tab has an image gallery. When I've tried to include both the image gallery and the spot where I hardcoded the image within <!-- templatecell : listing_image --><!-- /templatecell : image --> the gallery won't work correctly. Here is a link to the version with the hardcoded image (with the error - "_1.jpg"): http://www.mvp-recruiting.com/athletes/homepages/h0007.shtml Attached is the html for the above template and the one that doesn't use the hardcoded image (with broken image gallery). Thanks! Glenn
|
|
Attachments:
|
interactive-tools.txt
(41.4 KB)
|
|
|  |
 |

MikeB
Staff
/ Moderator

Mar 6, 2008, 3:09 PM
Post #4 of 6
(1270 views)
Shortcut
|
Hi Glenn, Thanks for the post and these details! Based on what you've mentioned here and directed me to it does seem like we'll need to use a bit of JavaScript to work around this. I've been playing around with this and I should have a script that you can use on your site to ensure that you don't run into any broken images. It sounds like you currently have an image tag that looks like this: <img src="$homepage_url$/images/$user_num$_1.jpg"> You'll want to replace the above line of code with this:
<script type="text/javascript"> function newImage() { var imageDetails=document.getElementById("homeImage"); var currentNum=imageDetails.name; currentNum++; if(currentNum<=20) { imageDetails.src="$homepage_url$/images/$user_num$_"+ currentNum +".jpg" imageDetails.name=currentNum; } else { imageDetails.src="http://www.mvp-recruiting.com/images/photo-soon-bk.jpg" } } var imageCounter=1; document.write('<img id="homeImage" src="$homepage_url$/images/$user_num$_'+ imageCounter +'.jpg" onError="newImage()" name="'+imageCounter+'">'); </script> Basically this JavaScript will first try to load "$user_num$_1.jpg". If it runs into an error(meaning that it can't find the image), it runs some JavaScript that increases this to "$user_num$_2.jpg" and tries outputting the image again. I've set this script up so it'll try all the way up to image 20 and if it doesn't find any images the script will use your default "No Photo" image that you've created (http://www.mvp-recruiting.com/images/photo-soon-bk.jpg). Give this a try and let me know how this works for you Glenn! Cheers, Mike Briggs - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 |

glennp
Novice
Mar 6, 2008, 5:27 PM
Post #5 of 6
(1268 views)
Shortcut
|
Hi Mike, I tried replacing the code with the script you sent. The script didn't display any images at all. As I think about it, that solution may not completely solve my problem anyway since the user will not have any control over which picture is displayed in that location. Any other thoughts are greatly appreciated! Glenn
|
|
|  |
 |

MikeB
Staff
/ Moderator

Mar 7, 2008, 1:46 PM
Post #6 of 6
(1250 views)
Shortcut
|
Hi Glenn, Thanks for posting! Aside from using this solution I can't really think of any other way to ensure that an image will always show up. The only other option I can think of is creating a new "Homepage" field where users can enter (or select) the image number they'd like to use for the "Home" section of their page. You could create a dropdown menu with a list of numbers, and allow them to pick which image number they'd like to use. In this case the only drawback is that the user would need to know the names of their images (1_1.jpg, 1_3.jpg, etc.) so they could choose which one they'd like to use. While this is a bit of a workaround it's the only method I can think of to give users full control over which image will show up. If you have any other questions or comments about this just let me know! Cheers, Mike Briggs - Product Specialist support@interactivetools.com
Hire me! Save time by getting our experts to help with your project. Template changes, advanced features, full integration, whatever you need. Whether you need one hour or fifty, get it done fast with Priority Consulting.
|
|
|  |
 | |  |
|