Socket
Socket
Sign inDemoInstall

django-image-dimensions

Package Overview
Dependencies
0
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    django-image-dimensions

Automatically add dimension attributes to all <img> tags in a response to improve rendering speed on the client.


Maintainers
1

Readme

======================= django-image-dimensions

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

  1. Run pip install django-image-dimensions
  2. 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 %}.

Keywords

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc