Skip to content
This repository was archived by the owner on Sep 22, 2020. It is now read-only.

Latest commit

 

History

History
30 lines (18 loc) · 972 Bytes

File metadata and controls

30 lines (18 loc) · 972 Bytes

Creating thumbnails

thumbnails.get_thumbnail should be used to generate thumbnails from python code. It takes the original image and size is positional arguments and needs to be passed each time the function is called. Other options can be passed as keyword arguments. The available options is listed below:

.. autofunction:: thumbnails.get_thumbnail


Django specific features

Templatetags

get_thumbnail

This templatetag is a shortcut for thumbnails.get_thumbnail, thus all arguments and keyword arguments are the same as described in the section above. It is necessary to define the variable name for the thumbnail with an as keyword as shown in the example below.

{% load thumbnails %}

{% get_thumbnail "image.jpg" "400x400" crop="center" as thumbnail %}
<img src="{{ thumbnail.url }}" alt="The thumbnail" style="width: {{ thumbnail.width }} />