Dummy thumbnails for most popular Django thumbnail generators.
Project description
Dummy thumbnails for most popular Django thumbnail generators.
There are times when you have a database of a Django site and you need to quickly start it up to fix/develop, but then you realise that images are missing and you need to have images, because either your layout is broken or, in the worst case, entire site is broken (500). This library has been written for developers in order to avoid above mentioned problems in the shortest way possible, with least efforts possible.
Prerequisites
Django 1.8, 1.9, 1.10
Python 2.7, 3.4, 3.5
Installation
Install in your virtual environment
Latest stable version from PyPI:
pip install django-dummy-thumbnails
Latest stable version from github:
pip install https://github.com/barseghyanartur/django-dummy-thumbnails/archive/stable.tar.gz
Add dummy_thumbnails to your INSTALLED_APPS in the global settings.py.
INSTALLED_APPS = ( # ... 'dummy_thumbnails', # ... )
Specify a custom path to your images directory:
DUMMY_THUMBNAILS_IMAGES_PATH = '/home/path/to/images/'
This should be a directory inside your media (or static) directory of your Django project. Otherwise Django would raise a SuspiciousOperation exception. In order not to duplicate tons of files for each project, you are advised to create symlinks to the images directory in the media (or static) directory of your Django project.
ln -s /home/path/to/images /home/repos/your-django-project/media
If you prefer to use included public domain images, run the following management commands:
./manage.py collectstatic --noinput ./manage.py dummy_thumbnails_symlink_dummy_images
And specify the following path:
DUMMY_THUMBNAILS_IMAGES_PATH = os.path.join(MEDIA_ROOT, 'mixed')
Usage
Common usage examples.
Replace broken images with dummy ones
That’s what it’s all about - replacing the broken images with dummy ones.
Supported thumbnailers
A number of most popular image thumbnailers for Django is supported. If you can’t find your favourite thumbnailer, open an issue or consider making a pull request.
easy-thumbnails
Integration with easy-thumbnails.
Modify your settings in the following way:
Add dummy_thumbnails to the INSTALLED_APPS:
INSTALLED_APPS = [ # ... 'easy_thumbnails', 'dummy_thumbnails', # ... ]
Add dummy thumbnail generator to THUMBNAIL_SOURCE_GENERATORS:
THUMBNAIL_SOURCE_GENERATORS = ( 'dummy_thumbnails.contrib.thumbnailers.easy_thumbnails.source_generators.dummy_thumbnail', )
If you are using the included images, don’t forget to collect the static files and create a symlink:
./manage.py collectstatic --noinput ./manage.py dummy_thumbnails_symlink_dummy_images
Now the following would work:
{% load thumbnail %} <img src=
"{% thumbnail 'None1' 640x480 crop %}"alt=""/> <img src="{% thumbnail 'None2' 480x640 crop %}"alt=""/> <img src="{% thumbnail 'None3' 200x200 crop %}"alt=""/>
sorl-thumbnail
Integration with sorl-thumbnail.
Modify your settings in the following way:
Add sorl.thumbnail to the INSTALLED_APPS:
INSTALLED_APPS = [ # ... 'sorl.thumbnail', 'dummy_thumbnails', # ... ]
Set the dummy thumbnail engine as THUMBNAIL_ENGINE:
THUMBNAIL_ENGINE = 'dummy_thumbnails.contrib.sorl_thumbnail.engines.DummyThumbnailsEngine'
If you are using the included images, don’t forget to collect the static files and create a symlink:
./manage.py collectstatic --noinput ./manage.py dummy_thumbnails_symlink_dummy_images
Now the following would work:
{% load thumbnail %} {% thumbnail 'None1' "640x480" crop="center" as im %} <img src=
"{{ im.url }}"width="{{ im.width }}"height="{{ im.height }}"/> {% endthumbnail %} {% thumbnail 'None2' "480x640" crop="center" as im %} <img src="{{ im.url }}"width="{{ im.width }}"height="{{ im.height }}"/> {% endthumbnail %} {% thumbnail 'None3' "200x200" crop="center" as im %} <img src="{{ im.url }}"width="{{ im.width }}"height="{{ im.height }}"/> {% endthumbnail %}
Testing
Simply type:
./runtests.py
or use tox:
tox
or use tox to check specific env:
tox -e py35
or run Django tests:
./manage.py test dummy_thumbnails --settings=settings.testing
License
GPL 2.0/LGPL 2.1
Support
For any issues contact me at the e-mail given in the Author section.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-dummy-thumbnails-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3fc2cc92419db80ce5671169df9c9eb77c82c1d0abd5c241dac092601cc093a |
|
MD5 | 0df34c97da53078b51c8e5eecc63bb2e |
|
BLAKE2b-256 | 135ff89d9b9771c2e0f119fe557d48c971795cbf65b955415ba4d76b8998ebf5 |
Hashes for django_dummy_thumbnails-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2687491e2c55a3560d651938d7eb2dbedf2638327c6e8622e5435c76b66681c9 |
|
MD5 | 1498400b8b8c0921ca59f7b2550612ce |
|
BLAKE2b-256 | 4cac166fc1fcc05da8f62c726f8ceb29be0b965abac8213342e256cf3ad91bbd |