Magnific popup: getting “The image could not be loaded” and image url is undefined

泪湿孤枕 提交于 2019-12-22 18:23:46

问题


I cannot make magnific popup work for some reason getting "The image could not be loaded" all the time. The image url is "undefined".

<div class="album">
    <a href="http://lorempixel.com/1024/768/?a=1">
        <img src="http://lorempixel.com/168/168/?a=1" />
    </a>
    <a href="http://lorempixel.com/1024/768/?a=2">
        <img src="http://lorempixel.com/168/168/?a=2" />
    </a>
    <a href="http://lorempixel.com/1024/768/?a=3">
        <img src="http://lorempixel.com/168/168/?a=3" />
    </a>
</div>

<script>
    $(function() {
        $('div.album').magnificPopup({ type: 'image' });
    });
</script>

http://jsfiddle.net/8vTYf/2/


回答1:


Changed the code to:

$(function() {
    $('div.album').magnificPopup({delegate: 'a', type: 'image' });
});

As from http://dimsemenov.com/plugins/magnific-popup/documentation.html#initializing_popup

The problem was you referred to the container instead of the 'a' element which contains the link to the image.



来源:https://stackoverflow.com/questions/18412335/magnific-popup-getting-the-image-could-not-be-loaded-and-image-url-is-undefin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!