SMF For Free Support Forum
SMF For Free Support => SMF For Free Codes and Support => Topic started by: Colette Brunel on November 25, 2008, 01:41:13 pm
-
Do you have a customized template that has images from all over the place? Have you ever had a problem where the image was moved/deleted, and your template screws up since the image failed to load?
Well, I have a solution! Every time you have an image that is unable to load, your templates will load a "default" image in place of it.
Make sure you have a reference to jQuery in your headers.
<script src="/jquery.js"></script>
In your headers, add the following:
<script language="javascript" type="text/javascript"><!-- // --><![CDATA[
$("img").error(function () {
$(this).unbind("error").attr("src", "http://somesite.com/images/broken.gif");
}); // ]]></script>
Replace "http://somesite.com/images/broken.gif" with the full path to the "default" loaded image.
-
hey thanks ccb im definatley gonna use it
-
Nice code. 8) I will use it!