开发者

help displaying thumbnail with sorl-thumbnail templatetag

I'm using sorl-sorl-thumbnail-v10.12.1-8-g0b7b514.

My issue is using the sorl-thumbnail templatetag to display an image. I'm following the documentation using the simpliest way to display an image.

In my template I have an object and so my template so far looks like this:

{% load thumbnail %}
<div class="post">
    <h2 class="title">{{ object.title }}</h2>
{% thumbnail object.logo "200x200" crop="center" as im %}
    <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}
</div>

The real problem comes here. This current code just displays the dummy image. In order for me to get the image to display I have to alter the code to:

{% thumbnail object.logo "200x200" crop="center" as im %}
    <img src="{{ object.logo.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}

If I change the "object" to "im" then I just get a dummyimage agin. Why is t开发者_开发百科his?


I think in your second example, which does display the image, you are simply showing the original image, but scaled down in browser, so there is no thumbnail processing going on (no resizing).

I suspect that you've got a problem with your settings, perhaps with MEDIA_URL. Can you find your original image in the file system (in the folder specified by upload_to on your model)? Can you find cached versions in MEDIA_URL/cached?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜