Skip to main content

Offload sorl thumbnail rendering to a render view.

Project description

https://badge.fury.io/py/async-thumbnail.png

Offload sorl thumbnail rendering to a render view.

Installation

pip install async-thumbnail

Usage

Note

Make sure you have sorl thumbnails configured.

# settings.py
INSTALLED_APPS = (
    # ...
    'async_thumbnail',
    # ...
)

# urls.py
urlpatterns = [
    # ...
    path('', include('async_thumbnail.urls')),
    # ...
]
{% load async_thumbnail %}

<!-- Default -->
<img src="{% async_thumbnail object.image "900x600" crop="center" %}">

<!-- Save as var -->
{% async_thumbnail object.image "900x600" crop="center" as im %}
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">

FetchFromCacheMiddleware

When you use the default full page caching middleware, it may be a good idea to replace it with this middleware. This prevents cache from being updated when the content contains a render URL.

Warning

In case you’re using things like source sets or lazy loading techniques this may be a bad idea.

# settings.py
MIDDLEWARE = (
    'django.middleware.cache.UpdateCacheMiddleware',
    # ...
    'async_thumbnail.middleware.FetchFromCacheMiddleware',
)

Settings

ASYNC_THUMBNAIL_ENDPOINT

  • Default: ''

Optional setting to determine an absolute path for rendering.

ASYNC_THUMBNAIL_PATTERN_NAME

  • Default: 'async_thumbnail:render'

Pattern name for render URL’s.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for async-thumbnail, version 2.0
Filename, size File type Python version Upload date Hashes
Filename, size async-thumbnail-2.0.tar.gz (8.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page