Settings

class easy_thumbnails.conf.Settings

These default settings for easy-thumbnails can be specified in your Django project’s settings module to alter the behaviour of easy-thumbnails.

THUMBNAIL_ALIASES = None

A dictionary of predefined alias options for different targets. See the usage documentation for details.

THUMBNAIL_BASEDIR = ''

Save thumbnail images to a directory directly off MEDIA_ROOT, still keeping the relative directory structure of the source image.

For example, using the {% thumbnail "photos/1.jpg" 150x150 %} tag with a THUMBNAIL_BASEDIR of 'thumbs' would result in the following thumbnail filename:

MEDIA_ROOT + 'thumbs/photos/1_jpg_150x150_q85.jpg'
THUMBNAIL_CACHE_DIMENSIONS = False

Save thumbnail dimensions to the database.

When using remote storage backends it can be a slow process to get image dimensions for a thumbnailed file. This option will store them in the database to be recalled quickly when required. Note: the old method still works as a fall back.

THUMBNAIL_CHECK_CACHE_MISS = False

If this boolean setting is set to True, and a thumbnail cannot be found in the database tables, we ask the storage if it has the thumbnail. If it does we add the row in the database, and we don’t need to generate the thumbnail.

Switch this to True if your easy_thumbnails_thumbnail table has been wiped but your storage still has the thumbnail files.

THUMBNAIL_DEBUG = False

If this boolean setting is set to True, display errors creating a thumbnail when using the {% thumbnail %} tag rather than failing silently.

THUMBNAIL_DEFAULT_OPTIONS = None

Set this to a dictionary of options to provide as the default for all thumbnail calls. For example, to make all images greyscale:

THUMBNAIL_DEFAULT_OPTIONS = {'bw': True}
THUMBNAIL_DEFAULT_STORAGE = 'easy_thumbnails.storage.ThumbnailFileSystemStorage'

The default Django storage for saving generated thumbnails.

THUMBNAIL_EXTENSION = 'jpg'

The type of image to save thumbnails with no transparency layer as.

Note that changing the extension will most likely cause the THUMBNAIL_QUALITY setting to have no effect.

THUMBNAIL_HIGHRES_INFIX = '@2x'

Sets the infix used to distinguish thumbnail images for retina displays.

Thumbnails generated for retina displays are distinguished from the standard resolution counterparts, by adding an infix to the filename just before the dot followed by the extension.

Apple Inc., formerly suggested to use @2x as infix, but later changed their mind and now suggests to use _2x, since this is more portable.

THUMBNAIL_HIGH_RESOLUTION = False

Enables thumbnails for retina displays.

Creates a version of the thumbnails in high resolution that can be used by a javascript layer to display higher quality thumbnails for high DPI displays.

This can be overridden at a per-thumbnail level with the ``HIGH_RESOLUTION``thumbnail option:

opts = {'size': (100, 100), 'crop': True, HIGH_RESOLUTION: False}
only_basic = get_thumbnailer(obj.image).get_thumbnail(opts)

In a template tag, use a value of 0 to force the disabling of a high resolution version or just the option name to enable it:

{% thumbnail obj.image 50x50 crop HIGH_RESOLUTION=0 %}  {# no hires #}
{% thumbnail obj.image 50x50 crop HIGH_RESOLUTION %}  {# force hires #}
THUMBNAIL_MEDIA_ROOT = ''

Used by easy-thumbnail’s default storage to locate where thumbnails are stored on the file system.

If not provided, Django’s standard MEDIA_ROOT setting is used.

THUMBNAIL_MEDIA_URL = ''

Used by easy-thumbnail’s default storage to build the absolute URL for a generated thumbnail.

If not provided, Django’s standard MEDIA_URL setting is used.

THUMBNAIL_PREFIX = ''

Prepend thumbnail filenames with the specified prefix.

For example, using the {% thumbnail "photos/1.jpg" 150x150 %} tag with a THUMBNAIL_PREFIX of 'thumbs_' would result in the following thumbnail filename:

MEDIA_ROOT + 'photos/thumbs_1_jpg_150x150_q85.jpg'
THUMBNAIL_PRESERVE_EXTENSIONS = None

To preserve specific extensions, for instance if you always want to create lossless PNG thumbnails from PNG sources, you can specify these extensions using this setting, for example:

THUMBNAIL_PRESERVE_EXTENSIONS = ('png',)

All extensions should be lowercase.

Instead of a tuple, you can also set this to True in order to always preserve the original extension.

THUMBNAIL_PROCESSORS = ('easy_thumbnails.processors.colorspace', 'easy_thumbnails.processors.autocrop', 'easy_thumbnails.processors.scale_and_crop', 'easy_thumbnails.processors.filters', 'easy_thumbnails.processors.background')

Defaults to:

THUMBNAIL_PROCESSORS = (
    'easy_thumbnails.processors.colorspace',
    'easy_thumbnails.processors.autocrop',
    'easy_thumbnails.processors.scale_and_crop',
    'easy_thumbnails.processors.filters',
    'easy_thumbnails.processors.background',
)

The Image Processors through which the source image is run when you create a thumbnail.

The order of the processors is the order in which they are sequentially called to process the image.

THUMBNAIL_QUALITY = 85

The default quality level for JPG images on a scale from 1 (worst) to 95 (best). Technically, values up to 100 are allowed, but this is not recommended.

THUMBNAIL_SOURCE_GENERATORS = ('easy_thumbnails.source_generators.pil_image',)

The Source Generators through which the base image is created from the source file.

The order of the processors is the order in which they are sequentially tried.

THUMBNAIL_SUBDIR = ''

Save thumbnail images to a sub-directory relative to the source image.

For example, using the {% thumbnail "photos/1.jpg" 150x150 %} tag with a THUMBNAIL_SUBDIR of 'thumbs' would result in the following thumbnail filename:

MEDIA_ROOT + 'photos/thumbs/1_jpg_150x150_q85.jpg'
THUMBNAIL_TRANSPARENCY_EXTENSION = 'png'

The type of image to save thumbnails with a transparency layer (e.g. GIFs or transparent PNGs).