3
嗨,我想知道为什么我的图像不出现。我认为它既存储为blobproperty也存储在blobstore中,因为它看起来像列表页面上的缩略图。在图像不会出现在地址页面是http://www.koolbusiness.com/servead/4125209为什么我的图像不显示?
来自同一图像的缩略图显示在列表中http://www.koolbusiness.com/li
我的一些模板代码显示的图像是:
{% if ad.matched_images.get %} <table><tr>
<td>
<div class="ad_pict" id="display_image"><img src="{{url}}" alt="" onload="show_hidden_elements();return false;"></div>
</td> <td>
{% ifequal len 1 %}
{% else %}
{% for im in imv %}
<div id="thumb0" class="ad_thumb ad_border_solid_black" onclick="showLargeImage('{{im}}');thumbnailBorder(this, 5)">
<table class="clean_table shadowed_thumb" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td><img src="/_/img/thumb_left_top.gif"></td>
<td class="top_middle" align="left" valign="bottom"></td>
<td></td>
</tr>
<tr>
<td class="middle_left"></td>
<td><img src="{{im}}=s120" alt="">
</td>
<td class="single_middle_right" valign="top"><img src="/_/img/thumb_single_right_top.gif"></td>
</tr>
<tr>
<td></td>
<td class="single_bottom_center" valign="top"><img src="/_/img/thumb_single_left_bottom.gif"></td>
<td valign="top"><img src="/_/img/thumb_single_right_bottom.gif"></td>
</tr>
</tbody>
</table>
</div>
{% endfor %}
{% endifequal %}
答索姆EOF我的服务器端的python加载模板是:
class AdHandler(I18NHandler):
def get(self, id):
ad = Ad.get_by_id(long(id))
if not ad:
self.error(404)
return
image = ad.matched_images.get()
url=''
if image:
if image.primary_image:
url = images.get_serving_url(str(image.primary_image.key()))
imv = []
table=''
for i in ad.matched_images:
if i.primary_image:
i1=images.get_serving_url(str(i.primary_image.key()))
imv.append(i1)
self.render_template("imageinfo.html", {'url':url,
'imv':imv,'len':len(imv),
'ad':ad,
'image': image,
'logout_url': users.create_logout_url('/'),
})
如果我用的是旧版本的页面的图片做了ppear所以很明显,我有它在数据库中,我只是写了一个错误,需要从blobproperty至Blobstore构建我的移民:http://www.koolbusiness.com/4125209
由于图像出现在后来的网址我知道它的存在和这只是我的代码中的一个错误,我无法重现,导致图像不显示。感谢您的帮助
谢谢!你完全正确。这是image.primary_image,有时评估为false。我不知道为什么,但至少现在我管理一个解决方法,添加一个子句'else:' – 2011-04-30 09:56:00