Package: django-dummy-thumbnails
Dummy thumbnails formost popularDjango
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.PrerequisitesDjango 1.8, 1.9, 1.10, 1.11, 2.0, 2.1, 2.2Python 2.7, 3.5, 3.6, 3.7Althoughdjango-dummy-thumbnailsis not being tested against older
versions of Django, tests do pass with Django versions 1.5, 1.6 and 1.7.InstallationInstall in your virtual environmentLatest stable version from PyPI:pipinstalldjango-dummy-thumbnailsor latest stable version from GitHub:pipinstallhttps://github.com/barseghyanartur/django-dummy-thumbnails/archive/stable.tar.gzor latest stable version from BitBucket:pipinstallhttps://bitbucket.org/barseghyanartur/django-dummy-thumbnails/get/stable.tar.gzAdddummy_thumbnailsto yourINSTALLED_APPSin the
globalsettings.py.INSTALLED_APPS=(# ...'dummy_thumbnails',# ...)Collect the statics:./manage.pycollectstatic--noinputSpecify a custom path to your images directory in settings:DUMMY_THUMBNAILS_IMAGES_PATH='/home/path/to/images/'This should be a directory inside your media directory of your Django
project. Otherwise Django would raise aSuspiciousOperationexception.
In order not to duplicate tons of files for each project, you are advised
to create symlinks to the images directory in the media directory of your
Django project.ln-s/home/path/to/images/home/repos/your-django-project/mediaIf you prefer to use includedpublic domain images,
run the following management command:./manage.pydummy_thumbnails_symlink_dummy_imagesAnd specify the following path in settings:DUMMY_THUMBNAILS_IMAGES_PATH=os.path.join(MEDIA_ROOT,'mixed')UsageCommon usage examples.Replace broken images with dummy onesThat’s what it’s all about - replacing the broken images with dummy ones.NoteYou shouldneveruse this in production. All the changes
mentioned above and below are supposed to be applied todevelopmentsettings only.Supported thumbnailersMost popular image thumbnailers for Django (django-imagekit,sorl-thumbnailandeasy-thumbnails) are supported. If you can’t find
your favourite thumbnailer, open an issue or consider making a pull request.django-imagekitIntegration withdjango-imagekit.Modify your settings in the following way:Addimagekit,dummy_thumbnailsanddummy_thumbnails.contrib.thumbnailers.django_imagekit.generatorlibraryto theINSTALLED_APPS:INSTALLED_APPS=[# ...'imagekit','dummy_thumbnails','dummy_thumbnails.contrib.thumbnailers.django_imagekit.generatorlibrary',# ...]Collect the statics:./manage.pycollectstatic--noinputSpecify a custom path to your images directory in settings:DUMMY_THUMBNAILS_IMAGES_PATH=os.path.join(MEDIA_ROOT,'mixed')If you are using the included public domain images, don’t forget to create
a symlink:./manage.pydummy_thumbnails_symlink_dummy_imagesNow the following would work:{% load imagekit %}

{% thumbnail '640x480' 'None1' %}
{% thumbnail '480x640' 'None2' %}
{% thumbnail '200x200' 'None3' %}sorl-thumbnailIntegration withsorl-thumbnail.Modify your settings in the following way:Addsorl.thumbnailanddummy_thumbnailsto theINSTALLED_APPS:INSTALLED_APPS=[# ...'sorl.thumbnail','dummy_thumbnails',# ...]Set the dummy thumbnail engine asTHUMBNAIL_ENGINE:THUMBNAIL_ENGINE='dummy_thumbnails.contrib.thumbnailers.sorl_thumbnail.engines.dummy_engine.DummyThumbnailsEngine'Collect the statics:./manage.pycollectstatic--noinputSpecify a custom path to your images directory in settings:DUMMY_THUMBNAILS_IMAGES_PATH=os.path.join(MEDIA_ROOT,'mixed')If you are using the included public domain images, don’t forget create a symlink:./manage.pydummy_thumbnails_symlink_dummy_imagesNow the following would work:{% load thumbnail %}

{% thumbnail 'None1' "640x480" crop="center" as im %}<imgsrc="{{ im.url }}"width="{{ im.width }}"height="{{ im.height }}"/>{% endthumbnail %}

{% thumbnail 'None2' "480x640" crop="center" as im %}<imgsrc="{{ im.url }}"width="{{ im.width }}"height="{{ im.height }}"/>{% endthumbnail %}

{% thumbnail 'None3' "200x200" crop="center" as im %}<imgsrc="{{ im.url }}"width="{{ im.width }}"height="{{ im.height }}"/>{% endthumbnail %}easy-thumbnailsIntegration witheasy-thumbnails.Modify your settings in the following way:Addeasy_thumbnailsanddummy_thumbnailsto theINSTALLED_APPS:INSTALLED_APPS=[# ...'easy_thumbnails','dummy_thumbnails',# ...]Add dummy thumbnail generator toTHUMBNAIL_SOURCE_GENERATORS:THUMBNAIL_SOURCE_GENERATORS=('dummy_thumbnails.contrib.thumbnailers.easy_thumbnails.source_generators.dummy_thumbnail',)Collect the statics:./manage.pycollectstatic--noinputSpecify a custom path to your images directory in settings:DUMMY_THUMBNAILS_IMAGES_PATH=os.path.join(MEDIA_ROOT,'mixed')If you are using the included public domain images, don’t forget to create a symlink:./manage.pydummy_thumbnails_symlink_dummy_imagesNow the following would work:{% load thumbnail %}<imgsrc="{% thumbnail 'None1' 640x480 crop %}"alt=""/><imgsrc="{% thumbnail 'None2' 480x640 crop %}"alt=""/><imgsrc="{% thumbnail 'None3' 200x200 crop %}"alt=""/>Dealing with broken or invalid dummy imagesOf course, it’s always better to have a good working set of dummy images.
However, it might happen that for some reason one of your dummy images
is broken.The recommended approach is to use a management commanddummy_thumbnails_verify_dummy_images, which has been written in order to
verify the dummy images and identify possible problems. It also lets you
remove broken/invalid dummy images.To remove broken/invalid dummy images with confirmation, type:./manage.pydummy_thumbnails_verify_dummy_imagesTo remove broken/invalid dummy images without confirmation, type:./manage.pydummy_thumbnails_verify_dummy_images--noinputTo just list broken/invalid dummy images without removal, type:./manage.pydummy_thumbnails_verify_dummy_images--listAnother way to avoid failures is to set the value ofDUMMY_THUMBNAILS_VERIFY_IMAGESto True in your project settings. Beware,
that this slows down the start up time of your Django project, although does
not slow down further rendering of the images.Importing images from feedImports images from feeds, that support enclosures.InstallationAdddummy_thumbnails.contrib.image_importers.feedto yourINSTALLED_APPSin the globalsettings.py.INSTALLED_APPS=(# ...'dummy_thumbnails.contrib.image_importers.feed',# ...)UsageTo import 50 dummy images from Flickrcommercialphotosfeed, type:./manage.pydummy_thumbnails_import_from_feedYou can provide a custom feed URL and the number of dummy images to import.
To import 100 images from Flickrnationalgeographicgroup, type:./manage.pydummy_thumbnails_import_from_feed\"https://api.flickr.com/services/feeds/groups_pool.gne?id=36256495@N00"\--limit=100ConfigurationAs you have seen, syntax allows to read images from any feed (that supports
enclosures). In your project, you might want to make it easy for developers,
so that they don’t have to type the feed URL. Therefore a settingDUMMY_THUMBNAILS_FEED_DEFAULT_FEED_URLhas been introduced. It defaults
to the URL of thecommercialphotosgroup of the Flickr.DUMMY_THUMBNAILS_FEED_DEFAULT_FEED_URL="https://api.flickr.com/"\"services/feeds/groups_pool.gne"\"?id=36256495@N00"DemoRun demo locallyIn order to be able to quickly evaluate thedjango-dummy-thumbnails, a demo
app (with a quick installer) has been created (works on Ubuntu/Debian, may
work on other Linux systems as well, although not guaranteed). Follow the
instructions below to have the demo running within a minute.Grab the latestdummy_thumbnails_demo_installer.sh:wget-O-https://raw.github.com/barseghyanartur/django-dummy-thumbnails/stable/examples/dummy_thumbnails_demo_installer.sh|bashOpen your browser and test the app.URL:http://127.0.0.1:8001/If quick installer doesn’t work for you, see the manual steps on running theexample project.TestingSimply type:./runtests.pyor use tox:toxor use tox to check specific env:tox-epy37or run Django tests:./manage.pytestdummy_thumbnails--settings=settings.testingLicenseGPL-2.0-only OR LGPL-2.1-or-laterSupportFor any issues contact me at the e-mail given in theAuthorsection.AuthorArtur Barseghyan <artur.barseghyan@gmail.com>