function imageLoadError(img) { const fallbackImage = '/media/sites/cnn/cnn-fallback-image.jpg'; img.removeAttribute('onerror'); img.src = fallbackImage; let element = img.previousElementSibling; while (element && element.tagName === 'SOURCE') { element.srcset = fallbackImage; element = element.previousElementSibling; } } Tom Williams/CQ-Roll Call, Inc./Getty Images

nexninja
0 Min Read

operate imageLoadError(img)
const fallbackImage=”/media/websites/Local News Patch/cnn-fallback-image.jpg”;

img.removeAttribute(‘onerror’);
img.src = fallbackImage;
let component = img.previousElementSibling;

whereas (component && component.tagName === ‘SOURCE’)
component.srcset = fallbackImage;
component = component.previousElementSibling;

Tom Williams/CQ-Roll Name, Inc./Getty Photographs

Source link

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *