django image optimization

Optimize Django ImageField media without changing upload storage

Keep originals in Django media storage, S3, a CMS, or your current public origin. Django templates can request Skymage URLs for exact dimensions, stable crops, WebP or AVIF output, and cached delivery.


# templatetags/skymage.py
from urllib.parse import urlencode
from django import template

register = template.Library()

@register.simple_tag
def skymage_url(source, **params):
    query = urlencode(params)
    return f"https://demo.skymage.net/v1/{source}{'?' + query if query else ''}"

{% skymage_url product.image.url w=520 h=390 fit="cover" f="webp" q=82 as product_image %}
<img src="{{ product_image }}" width="520" height="390" loading="lazy" alt="{{ product.name }}">
where it fits

Start with Django templates where media repeats

A useful Django image optimization test starts with one public route, one repeated template tag or include, and a measurable surface such as product cards, avatars, gallery images, or CMS media.

ImageField uploads

Request right-sized variants from public media URLs without creating new thumbnail records first.

Product and listing templates

Serve card, gallery, and detail images with explicit width, crop, format, and quality settings.

SaaS and marketplace media

Normalize avatars, screenshots, logos, and user uploads into predictable template sizes.

implementation

Keep URL generation in one Django template tag

A template tag or helper can centralize the Skymage prefix while each template asks for the dimensions it actually renders.


{% load skymage %}

{% skymage_url article.hero.url w=1280 h=720 fit="cover" f="avif" q=84 as hero_image %}
<img src="{{ hero_image }}" width="1280" height="720" alt="{{ article.title }}">

{% for item in products %}
  {% skymage_url item.image.url w=520 h=390 fit="cover" f="webp" q=82 as card_image %}
  <img src="{{ card_image }}" width="520" height="390" loading="lazy" alt="{{ item.name }}">
{% endfor %}
evaluation path

A practical Django image CDN test answers four questions

Origin fit

Can Skymage transform the public media URLs your Django app already renders?

Template slots

Can each repeated include request the exact dimensions it displays?

Format output

Can routes ship WebP or AVIF without changing uploads or background jobs?

Rollout risk

Can one template tag prove the pattern before changing every image view?

free check

Get a Django image route audit

Send one public Django route. The free audit will identify the repeated image surface to test first, the Skymage URL parameters to try, and whether the current media origin supports a low-risk rollout.

deploy

Start shipping lighter images.

Create a Skymage CDN URL, prepend it to your existing image URLs, and let the edge handle optimization, transforms, and delivery.

No credit card required. 14-day free trial.

Test one image-heavy page first. Paste a URL for a free check, or start a trial with the same tracked source.
Full form Start trial