0

I have made a news portal with Django that news add manually in database. I have used sorl-thumbnail for news images. But the client wants to add news from an external source that received from json.

I have to save image name in database and download image. Could I use sorl-thumbnail in second way? Or I have to change my all upload system?

halfer
  • 19,824
  • 17
  • 99
  • 186
TheNone
  • 5,684
  • 13
  • 57
  • 98
  • If you are receiving the json on the server (via `simplejson` for example), you can take the urls in the json and [download the full image using `urllib`](http://stackoverflow.com/questions/3042757/downloading-a-picture-via-urllib-and-python). You then use sorl on that image to create thumbnails – Timmy O'Mahony Oct 31 '13 at 19:25

1 Answers1

2

From sorl-thumbnail docs:

Using external images and advanced cropping:

{% thumbnail "http://www.aino.se/media/i/logo.png" "40x40" crop="80% top" as im %}  
    <img src="{{ im.url }}">
{% endthumbnail %}  

It is likely that you will need to do some changes to your models, but as far as sorl-thumbnail goes, it should have no problems with external images.

frnhr
  • 12,354
  • 9
  • 63
  • 90