Tipfy:如何在模板中显示blob? [英] Tipfy: How to display blob in template?

查看:137
本文介绍了Tipfy:如何在模板中显示blob?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于使用 tipfy (python)以下模式:

  greeting.avatar = db.Blob(avatar)

什么是模板标签显示一个blob(这里是图片)?

解决方案

在这种情况下,blob是一个很好的图像。只需使用 images.get_serving_url(blob_key) ,你很高兴。我已经使用了这个功能,相信我,这对于提供图片来说非常棒。只需将 = sxx 附加到其中 xx 是您想要的像素大小的网址中。它会自动调整图像大小并提供它。



如果blob不是图片,那么您很容易找到一条简单的出路。也许可以使用 BlobReader 做出一个字符串表示并输出它?

然而,如果它不是图像或文本,您可能想要写入HTML吗?

Given is on gae using tipfy (python) the following model:

greeting.avatar = db.Blob(avatar)

What is the template-tag to display a blob (here image)?

解决方案

In this case the blob is an an image, which is great. Just use images.get_serving_url(blob_key) and you're happy. I've used this function, and trust me, it is awesome for serving images. Just append =sxx to the url where xx is the pixel size you want. It automatically resizes the image and serves it.

If the blob isn't an image, then you're out of luck w.r.t an easy way out. Maybe use the BlobReader to make a string representation and output it?

If it isn't an image or text, though, what could you possibly want to write to HTML?

这篇关于Tipfy:如何在模板中显示blob?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆