Reputation: 13050
I'm building an auction website (in Python/Django). Users can provide URL's to their product images stored in external sites, for example images stored in Photobucket.
So my plan is that when displaying a specific auction, I'll link to the external product image. But when I'm showing list of auctions (e.g. a search results page) I'd need to show the thumbnails
I can see 2 options of doing this:
Use the externally hosted images as thumbnails as well. Specify a standardized small size for these images to "turn" them into thumbnails. How do I do that - do I specify the thumbnail size in the CSS or somewhere else? What would be a good size? Any code examples would be greatly appreciated as I'm not too familiar with CSS or HTML.
When the user submits an URL to an external image, download that image to my own server and turn it into a thumbnail. Any Python/Django software I can use for downloading the remote image and then turning it into a thumbnail?
Any general advices are appreciated. I'm leaning towards option (1) because I only have a cheap VPS and option (1) would be much less resource intensive. Any reason that is NOT a good idea?
Thanks.
Upvotes: 0
Views: 708
Reputation: 94222
I'm fairly sure I saw something exactly like this recently, where you could point a Django model field to a remote image URL and have thumbnails done, but you could also have it upload the image files too. Darned if I cant find it now.
Ah ha! Maybe sorl-thumbnail. Gives this example:
{% thumbnail "http://www.aino.se/media/i/logo.png" "40x40" crop="80% top" as im %}
<img src="{{ im.url }}">
{% endthumbnail %}
Assuming you can replace a literal string with a URL field (and not an ImageField) from your model ( lot.remoteimageurl for example) then I think that's it.
sorl-thumbnail will handle thumbnail creation and caching for you.
http://thumbnail.sorl.net/index.html#
Upvotes: 1
Reputation: 76063
Both will work.
I'm guessing that, if you googled for it a bit, you might even find an image resizer as a REST service, so you won't even have to implement it yourself (even though it's trivial) - you could just concatenate the url to some resizer service's url and be done with it.
** Edit **
Some googling found these tools:
Upvotes: 2