Skip to main content

Thumbnail maker for Django

Project description

Auto-generator of thumbnails for Django, using sorl-thumbnail.


  • Auto-genarates thumbnails using sorl-thumbnail while uploading (saving) images

  • You can use any engines & plugins you usually use with sorl-thumbnail

  • The application does not replace thumbnail templatetag and you can use everything you want from sorl-thumbnail

  • Command to auto-generate missing thumbnails

How to Use

Get the code

Get the code for the latest stable release use pip:

$ pip install django-thumbnail-maker

Configure your project

Register 'thumbnail_maker', in the INSTALLED_APPS section of your project’s settings anywhere after 'sorl.thumbnail' app (assume you already installed sorl-thumbnail):


Set up required thumb formats in THUMBNAIL_MAKER_FORMATS dictionary. Keys are the names for your formats (could be any string). Values are tuples of length 2: first element is a geometry string (used in sorl-thumbnail), second is a dictionary with options (crop, quality, padding, format, etc.):

    'banner':   ('400x300', {'crop': 'center',
                             'quality': 90}),
    '50x50':    ('50x50',   {}),
    'any_name': ('5x277',   {'padding': True})

You can set up THUMBNAIL_MAKER_DEBUG setting. By default it is set to False in order to pass exceptions while saving models or while generating batch of thumbnails. This setting is not required. Usage:


Set up your model’s field

Use ImageWithThumbnailsField and thumbs option, where thumbs is a tuple of thumb format names (keys from THUMBNAIL_MAKER_FORMATS dictionary):

from django.db import models
from thumbnail_maker.fields import ImageWithThumbnailsField

class Item(models.Model):
    image = ImageWithThumbnailsField(
        thumbs=('banner', '50x50'),

Templates usage

All of the examples assume that you first load the thumbnail_maker template tag in your template:

{% load thumbnail_maker %}

A simple usage:

{% usethumbnail item.image "banner" as im %}
    <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endusethumbnail %}

{% usethumbnail item.image "50x50" as im %}
    <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endusethumbnail %}

You can also use string paths instead of image objects:

{% usethumbnail "dummy/image.png" "50x50" as im %}
    <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endusethumbnail %}

Management commands usage

Django-thumbnail-maker comes with a command to generate missing thumbs. You can use it while

./ make_thumbnails <app>.<model> <field>

In case you want to make all thumbs replacing old ones, use --force option:

./ make_thumbnails --force <app>.<model> <field>

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-thumbnail-maker-0.0.6.tar.gz (560.4 kB view hashes)

Uploaded Source

Built Distributions

django_thumbnail_maker-0.0.6-py3-none-any.whl (8.8 kB view hashes)

Uploaded Python 3

django_thumbnail_maker-0.0.6-py2.py3-none-any.whl (8.8 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page