As mentioned in #871, when using the Image type and the <img> has no alt attribute, Magnific Popup's image.js on line 193 will erroneously replace the image with a new img where alt=String("undefined").
Problem line in Magnific Popup code (image.js:193):img.alt = item.el.find('img').attr('alt');
Problem description:As of jQuery version 1.6 (and Magnific Popup requires > 1.6) jQuery.attr() returns undefined if the attribute does not exist. When setting img.alt = undefined, undefined is converted to a String and the actual text "undefined" gets assigned.
As mentioned in #871, when using the Image type and the
<img>
has noalt
attribute, Magnific Popup's image.js on line 193 will erroneously replace the image with a newimg
wherealt=String("undefined")
.Problem line in Magnific Popup code (image.js:193):
img.alt = item.el.find('img').attr('alt');
Problem description: As of jQuery version 1.6 (and Magnific Popup requires > 1.6)
jQuery.attr()
returnsundefined
if the attribute does not exist. When settingimg.alt = undefined
, undefined is converted to a String and the actual text "undefined" gets assigned.Proof of Underlying Problem (in jQuery):
Solution/Fix: Test
item.el.find('img').attr('alt')
before assigningimg.alt
, as done in this PR.