Replace broken images

//Dev image replacement to fix broken images on dev site
cfReplaceDevImages('devdomain.us','http://livedomain.com');

function cfReplaceDevImages(devDomain,liveDomainUrl){
if(window.location.host.indexOf(devDomain) == -1) return false;
jQuery(window).bind('load', function(){
jQuery('img').each(function(){
if((typeof this.naturalWidth != "undefined" && this.naturalWidth == 0) || this.readyState == 'uninitialized'){
var oldUrl = jQuery(this).attr('src').replace(/^.*//[^/]+/, '');
var newUrl = liveDomainUrl + oldUrl;
jQuery(this).attr('src',newUrl);
}
});
})
}

0 Comments

You must be logged in to post a comment.