Skip to main content

A Django wrapper for RSZ.IO

Project description

A Django wrapper for https://rsz.io

Installation

Install via pip:

pip install django-rszio

Usage

  1. Add to INSTALLED_APPS in settings.py

  2. Add the include to urlpatterns in urls.py urlpatterns = [ ... url(r'^media/', include('rszio.urls')), ... ]

  3. Load the template tag into a template {% load rszio %}

  4. Use the image tag. {% image 'path/to/image.jpg' width=100 rotate=10 %} Visit the RSZ.IO Docs for all of the options. Convert parameters to kwargs.

Options

Prevalidate if the image exists in the default file storage

Add to settings.py

RSZIO_CHECK_EXISTS = True

The default is False

Cache Control headers

It is highly recommended that if you use this package your site should be sitting behind a CDN. Not sure what this is, check out https://www.cloudflare.com/

Add to settings.py

To set an expiration timeout use an integer in seconds. For example, below the image is set to cache for an hour.

RSZIO_CACHE_CONTROL = 3600

This will output Cache-Control max-age=3600 in the response header.

The advanced option

Any string you pass that doesn’t convert to an int will be set in the header.

RSZIO_CACHE_CONTROL = "no-cache"

This will output Cache-Control no-cache in the response header.

Caveats

  • KISS

  • The origional image must be accessable via a URL, so RSZ.IO can access it. I use django-storages with AWS S3 to serve my media.

  • This is tested and used in production with Django 1.10 and 1.11 on Python 3.5 and 3.6. But this should work on older versions of Django and Python 2. Open an issue or pull request if not the case.

Versioning

The package is following the Major.Minor.BugFix philosophy. So breaking changes will increase the major number. New features will increase the minor number.

So it is safe to put this line in your requirements.txt

All new features, no breaking features

django-rszio>=1.0.0,<2.0

Just bugfixes

django-rszio>=1.0.0,<1.1

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

django-rszio-1.0.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_rszio-1.0.0-py2.py3-none-any.whl (5.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-rszio-1.0.0.tar.gz.

File metadata

  • Download URL: django-rszio-1.0.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-rszio-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3b49578700d029f63c1b78a054ec985f2fb773bf9c38773c8e9e9f6e209c49e2
MD5 f78ec5cbbb79c7a75da7790ca5c562d8
BLAKE2b-256 1cb3efd927cd29ec2b31e9118829d6350fe46d7119d4dda145d6e053d2248f70

See more details on using hashes here.

File details

Details for the file django_rszio-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_rszio-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 49a045855ed5b4d20629208d1722acd1a49e579182d8649777f0e586c4559edb
MD5 c9f9069dc6e21b7ddd15fd06fe89934a
BLAKE2b-256 72d98523ff970d04d9a703a96a776f66fcc9292a1f1908ba5a929cf2490baed3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page