diff --git a/src/js/image.js b/src/js/image.js index f5687c85..fc389c6e 100644 --- a/src/js/image.js +++ b/src/js/image.js @@ -190,7 +190,11 @@ $.magnificPopup.registerModule('image', { var img = document.createElement('img'); img.className = 'mfp-img'; if(item.el && item.el.find('img').length) { - img.alt = item.el.find('img').attr('alt'); + // Sometimes the img does not have an alt attribute. jQuery 1.6+ will + // then return /undefined/, setting img.alt=String("undefined"). + if(item.el.find('img').attr('alt')) { + img.alt = item.el.find('img').attr('alt'); + } } item.img = $(img).on('load.mfploader', onLoadComplete).on('error.mfploader', onLoadError); img.src = item.src;