Can I add code to template to replace / delete / hide all the broken images on my site?


Author Message
mplsdancehall

Posted: 12/18/2014
Quote message 

Before I migrated from J1.5, I failed to backup all my image files so now I have a TON of broken images on my site. I've Googled and found some advice to add Javascript and/or jQuery script to my site, but the advice is a few years old (is it still valid code?) and I don't know a lot about the code to know how to even incorporate it correctly, but I thought maybe I can edit into the template's head in the export options when using Artisteer.

I would like to replace the broken image with an image of my own choosing, or if it can just be a blank space with no white outline - or preferably no space at all! :) (to be continued in comments)

Thanks!!
~ sara
 
mplsdancehall

Posted: 12/18/2014
Quote message 

Here is the rest of my message....

This is the suggested Javascript:
(function(){ for(i=0;i<nodes.length;i++){ nodes.onerror=nodes.src='http://exampledomain.com/path-to-default-image'; } })();


This is a suggested jquery:
$(document).ready(function(){ $("img").each(function(){ $(this).attr("onerror","this.src='http://exampledomain.com/path-to-default-image'"); }); });


This is another suggested jQuery:
// Replace source $('img').error(function(){         $(this).attr('src', 'missing.png'); });   // Or, hide them $("img").error(function(){         $(this).hide(); });


Do any/all of these look valid? and if so, where/how exactly would I add them - either in the Artisteer program, or in the Joomla backend Template manager? I've tried some of the codes in the export options in Artisteer but whatever I did, did not seem to work.

- - - -

Alternately, if anyone knows any other tricks/tips for completely deleting each broken image completely - maybe something in the database? or a Joomla extension.... any advice is greatly appreciated!!!

Thanks!!
 

Reply


NAME *
EMAIL
SMILIES :-) :( :-D 8-) :*) :-/ :-{} :-X :-O :-@ O:) :-P :-< :-( :-| ;-) 
CODES [Quote] [B] [I] [U] [Code] [IMG] 
BODY *  
VALIDATION *