Automatically add dimension attributes to all <img> tags in a response to improve rendering speed on the client.
Project description
Automatically add dimension attributes to all <img> tags in a response to improve rendering speed on the client.
Rationale
Specifying image dimensions in HTML improves both percieved and actual client-side rendering performance by preventing reflow. However, maintaining explicit dimensions in templates is tedious and impractical in some cases. This middleware solves that in a plug-and-play manner by automatically setting dimensions in all &img& tags in a response.
Requirements
django-celery to run image fetch and dimensions calculations in the background
PIL
A cache that is shared between web server and celery (e.g. memcached)
Installation
Run pip install django-image-dimensions
Add ‘imagedimensions’ app to INSTALLED_APPS
Usage
For a quick test-drive add ‘imagedimensions.middleware.ImageDimensionsMiddleware’ to MIDDLEWARE_CLASSES. However, this is not suitable for production use as it adds an overhead to every request. For production, replace {% load cache %} in your templates with {% load imgdimensions %}.
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
Built Distribution
Hashes for django-image-dimensions-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6e98e82f351896d9f6111b4b5b859c2a4990ed389530864af5b1c15b6c7f1d2 |
|
MD5 | a125928f8581f9c32dd17f5e7c0f4694 |
|
BLAKE2b-256 | b427d767a98eb75a6dadf490a991107c5127a214a9dfd9c71af6f93898b1d7b1 |
Hashes for django_image_dimensions-0.0.3-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd9c16b1ba0a734cb3476ff6e0884a51b8517150aaf2dfaa7167192aea369203 |
|
MD5 | 82bca623e911864fff381122d7739a78 |
|
BLAKE2b-256 | 6cf236f6cb10067ef9bc703fd502d716b86bfb7de80174acef94f6ee8ab8a4d3 |