The site moved to a new domain, but not all the pictures were transferred to the new addresses. It is necessary to rewrite the addresses of the lost pictures of the article_image class to the addresses from the old domain. Addresses differ only in the domain name. I write on jquery:

$('img.article_image').on('error', function() { $(this).attr('src').replace('new-domain.ru', 'old-domain.ru'); }); 

Does not work. Previously asked a question with galleries - it worked. Now need for news

  • one
    replace does not modify the string, but returns the modified string. - Stepan Kasyanenko

1 answer 1

$(this).attr('src',$(this).attr('src').replace('new-domain.ru', 'old-domain.ru'));