编辑:问题可以在这里看到: http: //school.collegebrain.com/images/university-of-washington/。它只发生了 1/15 次,但这仍然太频繁了。
我有以下 Django 模板:
<script type="text/javascript" src="{{ STATIC_URL }}js/
jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" href="{{ STATIC_URL }}css/
jquery.fancybox-1.3.4.css" type="text/css" media="screen" />
{% include "submission-form.html" with section="photos" %}
<div class="commentables">
{% load thumbnail %}
{% for story in objects %}
<div class="image {% if forloop.counter|add:"-1"|
divisibleby:picsinrow %}left{% else %}{% if forloop.counter|
divisibleby:picsinrow %}right{% else %}middle{% endif %}{% endif %}">
{% if story.image %}
{% thumbnail story.image size crop="center" as full_im %}
<a rel="gallery" href="{% url post slug=story.slug %}">
<img class="preview" {% if story.title %}
alt="{{ story.title }}" {% endif %} src="{{ full_im.url }}" full-
image="{% if story.image_url %}{{ story.image_url }}{% else %}
{{ story.image.url }}{% endif %}">
</a>
{% endthumbnail %}
{% else %}
{% if story.image_url %}
{% thumbnail story.image_url size crop="center" as
full_im %}
<a rel="gallery" href="{% url post slug=story.slug %}">
<img class="preview" {% if story.title %}
alt="{{ story.title }}" {% endif %} src="{{ full_im.url }}" full-
image="{{ story.image_url }}">
</a>
{% endthumbnail %}
{% endif %}
{% endif %}
</div>
{% endfor %}
{% if rowid != "last" %}
<br style="clear: both" />
{% endif %}
{% if not no_more_button %}
<p style="text-align: right;" class="more-results"><a href="{% url
images school_slug tag_slug %}">more...</a></p>
{% endif %}
</div>
<script>
$(document).ready(function(){
function changeattr(e){
var f = $(e.clone());
$(f.children()[0]).attr('src', $(f.children()
[0]).attr("full-image"));
$(f.children()[0]).attr('height', '500px');
return f[0].outerHTML;
}
$('.image a').each(function(idx, elem) {
var e = $(elem);
e.fancybox({
title: $(e.children()[0]).attr('alt'),
content: changeattr(e)
});
});
});
</script>
我偶尔会遇到奇怪的显示错误,盒子要么根本不渲染任何东西(所以它基本上只会显示为一个细白条),或者它只会渲染大约 30 px 宽,并将自身定位在中间页。在这两种情况下,如果我检查元素,我可以看到完整图片的“阴影”,大小合适,url 正确。
图像源似乎没有什么不同,我没有收到任何错误,这在 chrome 和 firefox 中都发生了。有没有人有任何想法?
编辑:一个混乱的盒子上的视图选择源给出
<div id="fancybox-outer"><div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div><div style="border-width: 10px; width: 165px; height: auto; opacity: 1;" id="fancybox-content"><div style="width: auto; height: auto; overflow: auto; position: relative;"><a rel="gallery" href="/post/shit-is-about-to-get-real/">
<img class="preview" alt="shit IS about to get real" src="http://i.imgur.com/Le8Kv.jpg" full-image="http://i.imgur.com/Le8Kv.jpg" height="500px">
</a></div></div><a style="display: inline;" id="fancybox-close"></a><a style="display: inline;" href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a><a style="display: inline;" href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a></div>