Offload sorl thumbnail rendering to a render view.
Project description
Offload sorl thumbnail rendering to a render view.
Installation
pip install async-thumbnail
Usage
# 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.
# 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.
Source Distribution
async-thumbnail-2.2.tar.gz
(8.1 kB
view details)
File details
Details for the file async-thumbnail-2.2.tar.gz
.
File metadata
- Download URL: async-thumbnail-2.2.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 293ddd25da4ac53a47d41cc6fe04f838b1369925f22f292cb7b046ce3948da6e |
|
MD5 | f3eed61b1177dab9a1ee6879738796d7 |
|
BLAKE2b-256 | 302e24d936e69577841fed95f30da3d0934d27c2b03a9ce0fda4b9b08be8c0c0 |