Skip to main content

A django application to resize images using the thumbor service

Project description

CI status on Travis CI Latest django-thumbor PyPI version Number of downloads for django-thumbor on PyPI Code coverage on Coveralls

A django application to resize images using the thumbor service.

Usage

Both thumbor_url templatetag and the generate_url helper uses the same arguments as libthumbor, you can check the wiki for more info.

On templates:

{% load thumbor_tags %}
<img src="{% thumbor_url '/media/image.jpg' width=300 %}" width="300" />

On code:

from django_thumbor import generate_url
resized = generate_url("/media/image.jpg", width=300)

There is an extra parameter to specify a custom server to be used instead of settings.THUMBOR_SERVER.

On templates:

{% load thumbor_tags %}
<img src="{% thumbor_url '/media/image.jpg' thumbor_server='http://localhost:8888/foo' width=300 %}" width="300" />

On code:

from django_thumbor import generate_url
custom_server = "http://localhost:8888/foo"
resized = generate_url(
    "/media/image.jpg", thumbor_server=custom_server, width=300)

Installation

pip install django-thumbor

Configuration

Add the app to the INSTALLED_APPS:

INSTALLED_APPS = (
    # ...
    'django_thumbor',
)

Here are the default settings that you can override:

# The host serving the thumbor resized images
THUMBOR_SERVER = 'http://localhost:8888'

# The prefix for the host serving the original images
# This must be a resolvable address to allow thumbor to reach the images
THUMBOR_MEDIA_URL = 'http://localhost:8000/media'

# The same security key used in the thumbor service to
# match the URL construction
THUMBOR_SECURITY_KEY = 'MY_SECURE_KEY'

# Default arguments passed to the `generate_url` helper or
# the `thumbor_url` templatetag
THUMBOR_ARGUMENTS = {}

Contributing

Install

Fork, clone, create a virtualenv and run:

git clone git://github.com/ricobl/django-thumbor.git
mkvirtualenv django-thumbor
make install

Test

Add tests on testproject/tests, add code and run:

make test

Authors

@ricobl @avelino @Starou

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-thumbor-0.4.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file django-thumbor-0.4.tar.gz.

File metadata

File hashes

Hashes for django-thumbor-0.4.tar.gz
Algorithm Hash digest
SHA256 8e76efcc52dbba425f8e1989d6975a0b91ed3cce6d988675a7ecbd315b7aea6e
MD5 20f3b40baa3c752f9fbaa7a8f9fc6b5c
BLAKE2b-256 8a736b5b0899a71a8e958b11c1708551dea177ff2e3a9c4ef6ddb2d70fb0c921

See more details on using hashes here.

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