sorl-thumbnail不创建缩略图 [英] sorl-thumbnail not creating thumbnails

查看:111
本文介绍了sorl-thumbnail不创建缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 sorl-thumbnail 中遇到困难。

我的模板如下:

{% thumbnail project.image "75x75" crop="center" as im %}
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% empty %}
<p>:(</p>
{% endthumbnail %}

在我呈现的网页中,我得到以下缩略图路径:

In my rendered webpage I get the following path for the thumbnail:

< img src =/ media / cache / ff / 29 / ff299c50543aa807b0fbd28faf271e63.jpgwidth =75height =75>

这一切都是有道理的,因为我的 MEDIA_URL 被设置为 / media / ,它映射到我的apache httpd.conf 到我的服务器上的本地文件夹。

Now this all makes sense because my MEDIA_URL is set as /media/ which is mapped in my apache httpd.conf to a local folder on my server.

问题是这个路径不存在于服务器上,所以图像是显示为一个破碎的链接。

The problem is that this path does not exist on the server so the image is displayed as a broken link.

值得注意的是,我使用自定义存储对象,虽然这不应该影响的东西,直接通过 sorl.thumbnail ImageField 。我还使用服务器上运行的 memcached 缓存后端。

It's worth noting I am using a custom storage object although this shouldn't affect things as it's passed straight through the sorl.thumbnail ImageField. Also I am using a memcached cache backend running on the server.

令人讨厌的是,即使我有 THUMBNAIL_DEBUG 一个也没有任何错误d DEBUG ,所以很难看出是怎么回事。我相当确定将缩略图文件写入磁盘,但返回成功,因为 {%empty%} 语句未被触发,相应的缓存文件做不出现在服务器上。我不知道为什么,因为没有任何错误。

The annoying thing is that I don't get any errors even though I have THUMBNAIL_DEBUG and DEBUG on so it's difficult to see what's going wrong. I'm fairly sure it's failing to write the thumbnail files to disk but returning as successful because the {% empty %} statement doesn't get triggered and the appropriate cache files do not appear on the server. I don't know why though due to the lack of any error.

我有点困在这一点,所以任何帮助将不胜感激。

I'm kinda stuck at this point so any help would be appreciated.

编辑:

现在我已经放弃了sorl,而使用简单的缩略图代替了正常工作。 >

I've given up with sorl now and am using easy-thumbnails instead which is working fine.

推荐答案

我和你有非常相似的问题,我不能使用简单缩略图因为我需要从外部源创建缩略图。我所想出的是在开始使用与开发相同的数据库,所以在渲染图像开发之后,它将缓存的文件名存储到数据库中,当您尝试在分段时渲染时,它会从相同的文件名中提取文件名数据库,但显然这些文件不在上架。

I have had very similar problem with you, I cannot use easy-thumbnails because I need to create thumbnails from external source. what I have figured out is on staging is using the same database as development, so after I rendered the images on development, it stores the cached filenames into database, and when you try to render on staging, it picks up the filenames from the same database, but obviously the files are not on staging.

尝试运行

./manage thumbnail clear

这篇关于sorl-thumbnail不创建缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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