gista / summer-cesta-snp

Web mapping application for 'Cesta SNP' project. Gista Open Summer 2011
http://opensummer.cestasnp.sk/
2 stars 1 forks source link

Implement 'sorl-thumbnail' for working with thumbs #51

Closed imincik closed 13 years ago

imincik commented 13 years ago

Implement 'sorl-thumbnail' for working with thumbs from uploaded photos.

source: https://github.com/sorl/sorl-thumbnail

lOlIl commented 13 years ago

OK. It works well but... The problem is to solve it with API.

From GET request in /mapdata/poidetail?id=xy I get JSON e.g. "photos_map":[1,3,5], "photos_jos":[2,4,6]

These are IDs of images, which I request from server in html IMAGE tag.

But sorl-thumbnail is excepting external images or ImageField/FileField.

if I request from our server (as written in examples http://thumbnail.sorl.net/examples.html#template-examples) an image,

{% thumbnail "/media/1/" "100x100" as im %} (where 1 is ID from poidetail response) ... {% endthumbnail %}

the page will be never reloaded. (In my opinion it is not good to solve it so, that I will twice request 1 image... firstly one for getting the basic image & secondly to get thumb image)

So I used low-level-api (http://thumbnail.sorl.net/examples.html#low-level-api-examples) with combination of GET paramether e.g. IMG src="/media/1/?r=100x100".

Of course, there can be default resolution variable in SETTINGS.