Skip to main content

A Django wrapper for https://rsz.io

Installation

Install via pip:

pip install django-rszio

Usage

  1. Add to INSTALLED_APPS in settings.py 'rszio',

  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

Metadata

Release files for django-rszio 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-rszio 1.1.0
File Size Uploaded
django-rszio-1.1.0.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-rszio 1.1.0
File Interpreter ABI Platform
django_rszio-1.1.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 12.8 kB

Release files / django-rszio-1.1.0.tar.gz

Download URL django-rszio-1.1.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bab716bbaeaa36ea320276caa1f96dc8316948ed154ad5ae4f58602c978ae3c7
BLAKE2b-256 checksum
How to use checksums
d639249649f7d4fbef2166df4f9a6f6e2de4864ee6d9d03b7703530159810531
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_rszio-1.1.0-py2.py3-none-any.whl

Download URL django_rszio-1.1.0-py2.py3-none-any.whl
Size 7.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b039153a86fd7a6ac1c4e24bf090a583a42d07215ec44416b68487866c93a647
BLAKE2b-256 checksum
How to use checksums
9e144d113eb8513f7f90c0e91e68e27856f893fbb00771aba04ba8998dbd83bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page