Question

can someone please give me an example of how to change the SORL-thumbnail format in the django template tag.

I've read the documentation here: http://thumbnail.sorl.net/template.html#thumbnail

and have tried various ways of implimenting to no avail. I get errors similar to: 'thumbnail' tag received a bad argument: 'format'

My code works fine without the " format="png" " part, it just makes a jpg thumbnail. However, I want a png thumbnail. {% thumbnail product.main_image.picture 84x84 format="png" as image %}

Also, adding THUMBNAIL_FORMAT = "PNG" to my settings.py did nothing

Thanks,



UPDATE: HERE's HOW I FIXED THE PROBLEM:

So Issac and zachwood were right on. This was a version dependent thing. I resolved my problem this way:

1.) upgrade to newest sorl
1.1) syncdb
2.) in settings, changed THUMBNAIL_DEBUG = True
3.) added closing tag so the templates looked like :

        {% thumbnail product.main_image.picture "400x284" format="PNG"  as image %}

<img src="{{ media_url }}{{ image }}" width="{{ image.width }}" height="{{ image.height }}" alt="{{ product.short_description }}"/>

        {% endthumbnail %}

It worked!

4.)

Was it helpful?

Solution

Unfortunately Satchmo uses SORL-Thumbnail version 3.2.5, those docs are for 11. My guess is they didn't support formats in version 3.x. I haven't had any luck finding docs for it but you can probably dig through the code to be sure.

If I remember correctly you can swap out the library for version 11, but you'll have to go through all the templates that use the template tag and add the {% endthumbnail %} tag after each time it's used (the endtag wasn't used back in version 3.x).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top