2

I'm trying to get Sorl-thumbnail running on my staging server, but I'm running into a TemplateSyntaxError which is throwing me since the app works fine on localhost.

The error is coming in at {% endthumbnail %}

TemplateSyntaxError at /home/
Invalid block tag: 'endthumbnail', expected 'endif'

Any help would be greatly appreciated. Thanks!

{% load thumbnail %}

{% if picture.photo_medium %}
    <img src="{{AWS_URL}}{{picture.photo_medium}}" class="imagepage" width="400" height="300">
{% else %}
    {% if picture.photo_large|is_portrait %}
       <div class="portrait">
          {% thumbnail picture.photo_large "400" crop="center" as im %}
          <img src="{{AWS_URL}}{{ im }}">
       </div>
    {% else %}
       <div class="landscape">
          {% thumbnail picture.photo_large "400" crop="center" as im %}
          <img src="{{AWS_URL}}{{ im }}">
       </div>
    {% endif %}
{% endif %}
Emile
  • 3,464
  • 8
  • 46
  • 77
  • And I am calling {% load thumbnail %} further up the page. Just in case someone wonders about that – Emile Apr 21 '11 at 06:51
  • I really don't see the problem, everything should work fine. Try experementing, by removing the {% if %} block, what will happen? – Silver Light Apr 21 '11 at 08:42

4 Answers4

4

It is likely that you have an older version of sorl-thumbnail installed on your localhost than is installed on your staging server. The endthumbnail tag was added relatively recently as part of a major rewrite.

If you find that you need to upgrade you may find the setting THUMBNAIL-DEBUG helpful for tracking down other problems.

Jesse
  • 373
  • 3
  • 5
  • Yep - deleting all references to sorl on the host and then re-running "pip install sorl-thumbnail" fixed it for me. – shacker Aug 24 '11 at 20:19
2

I might be wrong, but I don't think you need the {% endthumbnail %} tag.

Herman Schaaf
  • 46,821
  • 21
  • 100
  • 139
  • 1
    According to docs (http://thumbnail.sorl.net/examples.html#template-examples) he does. – Silver Light Apr 21 '11 at 08:37
  • Well, that doesn't work for me either - I don't know how it can work on the local server at all. I've always used it without the endthumbnail tag - with it, I get the same error (always). – Herman Schaaf Apr 21 '11 at 13:05
  • 1
    Bizarre - the solution was removing the endthumbnail, even though the docs use it. – Emile Apr 21 '11 at 13:15
  • @Herman One more question, I'm now getting Invalid filter:'is_portrait' and I'm wondering if you have yours setup differently than the docs when you use that too. I've posted the full code above. Thanks! – Emile Apr 21 '11 at 13:53
  • @Emile: Sorry, never used that option - however, I used `grep -r "portrait" *` in my sorl folder, and there's no mention of any `is_portrait` filter (the word `portrait` isn't anywhere to be seen) - so either it's a feature in a newer version of sorl, or it hasn't been implemented yet (or deprecated)! – Herman Schaaf Apr 21 '11 at 14:07
  • Ultimately the bug was with the version of Sorl on the server. Updated 11.04 – Emile Apr 21 '11 at 14:51
  • The answer above should be UNaccepted as the correct answer, as it's based on an old version of the lib. Jesse's answer below should be marked as accepted. – shacker Aug 24 '11 at 20:20
  • I am getting this error with sorl-thumbnails 11.12. If I remove the `{% endthumbnail %}`, then it works again. – toto_tico Feb 15 '14 at 01:15
0

The problem can also be with loading template tags.

I was doing {% load thumbnail %} in base html. When I call below code in inherited html, got same error.

{% thumbnail service_type.pic.image "100x100" crop="center" as im %}
   <img .....>
{% endthumbnail %} 

See this discussion about loading template tags in base.html

Community
  • 1
  • 1
naren
  • 14,611
  • 5
  • 38
  • 45
0

I just ran into this problem in using SORL Thumbnail in Mezzanine. Apparently Mezzanine loads it's own thumbnailer, so if you {% load thumbnail mezzanine_tags %}, mezzanine's thumbnail takes over from SORL's Thumbnail tag. However, if you reverse it {% load mezzanine_tags thumbnail %}, it works fine.

Lesson Learned: Make sure other libraries you're using aren't inadvertently taking over, and just to be safe maybe load thumbnail last.

K3TH3R
  • 734
  • 5
  • 12