django-thummer’s documentation¶
A website screenshot and thumbnailing app for Django. Uses firefox, selenium, sorl-thumbnail, and celery.
Contents:
Setup¶
Requirements¶
django-thummer requires Firefox and Xvfb. On Debian/Ubuntu systems these can be installed using:
sudo apt-get install firefox xvfb
Installation¶
django-thummer can be installed to your Python environment using pip:
pip install django-thummer
Then add thummer
to INSTALLED_APPS
in your Django settings file, and
sync the database. If you’re using South, then
migrations are provided.
Using Celery for background thumbnail capture¶
It is highly recommended to use Celery for background thumbnail capture. By default, django-thummer will automatically use Celery if it is available. Both celery and django-celery can be installed to your Python environment using pip:
pip install django-celery
Configuring celery can be tricky, and you should carefully read both the django-celery documentation and celery documentation.
Basic API Example¶
from thummer import get_thumbnail
thumbnail = get_thumbnail('http://www.example.com/', '400x400')
Template Tag¶
{% load thummer %}
{% thummer "http://www.example.com/" "400x400" as thumb %}
<img src="{{ thumb.url }}" alt="" />
{% endthummer %}
Reference:
Settings¶
THUMMER_PLACEHOLDER_DEFAULTS
¶
Default: {'crop': 'center', 'upscale': False, 'format': 'PNG'}
(Dictionary)
A keywords dictionary passed to sorl.thumbnail
when generating placeholder
thumbnails.
THUMMER_PLACEHOLDER_PATH
¶
Default: 'thummer/placeholder.png'
(String)
The path to the placeholder image in your staticfiles
storage.
THUMMER_QUEUE_SNAPSHOTS
¶
Default: True
(Boolean) if 'djcelery'
is in Django’s
'INSTALLED_APPS'
setting.
Determine if thumbnail generation should be queued for background processing
using django-celery
(recommended).
THUMMER_SNAPSHOTS_VALID_FOR
¶
Default: dateutil.relativedelta.relativedelta(months=+3)
(A dateutil
relativedelta of 3 months)
The period of time that a thumbnail snapshot of a url is valid for, before a new thumbnail is generated.
THUMMER_STORAGE
¶
Default: django.core.files.storage.default_storage
(Django’s configured
default storage)
Storage instance to use for thumbnail media.
THUMMER_THUMBNAIL_DEFAULTS
¶
Default: {'crop': 'left top', 'upscale': False, 'format': 'JPEG'}
(Dictionary)
A keywords dictionary passed to sorl.thumbnail
when generating thumbnails.
THUMMER_UPLOAD_PATH
¶
Default: 'thummer/snapshots'
(String)
The path prefix to store thumbnails under in THUMMER_STORAGE
.
Credits¶
Special thanks to the sorl-thumbnail, selenium, PyVirtualDisplay, and celery, projects. Thanks also to the blog posts which originally got me thinking about the project: