How to specify size of thumbnails for photos that are hosted externally?

Tags: html,css,django,image,thumbnails

Problem :

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:

  1. 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.

  2. 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?


Solution :

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 "" "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.

    CSS Howto..

    How to select where my overflow ellipsis starts

    How Do I Make Li Clickable for Radio Button Inside

    How to change image size on featured images in wordpress?

    How to change the scrollbar color using css [duplicate]

    How to get Susy going with a CSS only toggle navigation

    How to show “…” when there's not enough space to view all the text

    custom radio button show value inside

    How to do a darker background image in css3 and stretch it?

    How to load and apply a CSS stylesheet at runtime in a Flex application?

    How can I put element in the middle of vertical align?

    How to set caption for youtube videos box in css?

    How to sharpen an image in CSS?

    Centered CSS pages that are longer than one screen appear 5px~ further to the left than shorter ones - how do I stop this?

    How to make two buttons in column?

    How to measure the amount of time an animation took place using JavaScript

    How to get CSS to E-Mails back in Magento 1.9.1

    How to create this style of nav bar using exclusively HTML5 and CSS?

    How to get css3 multi-column count in Javascript

    How to get Jsfiddles working on a website? [duplicate]

    How to create a smooth zoom and display an overlay when another HTML element gets hovered?

    How to make this arrow in CSS only?

    how do I properly position & scale these elements in CSS?

    How do I get one element to respond to the click of another element? - CSS/jQuery

    CSS Grow on hover adds padding to the bottom of an image, how do I stop this from happening?

    How do I animate my CSS progress bar?

    How to override html property created by script (mediaelement.js)

    CSS Chevron Showing Unwanted Rectangle

    How to Scale Down a Large Image Using HTML and/or CSS

    How do I use CSS to add a non-rectangular border around an image?

    How to customize CSS depending on (tinier) window size?