Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Simple Django Image Proxy especially for Horizon Openstack Dashboard.

Project Description

Simple django app which provide images from remote hosts. Supports custom sizes and simple caching for less API calls.

Aims to simplicity and compatibility with Openstack Horizon Dashboard, where is main place for usage.

Supports

  • Django 1.7 and older
  • Openstack Horizon Dashboard Icehouse, Juno +
  • Pillow 2.3.0

Installation

pip install django_image_proxy

local_settings.py

INSTALLED_APPS += ('image_proxy',)

IMAGE_PROXY_URL = 'http://localhost:9753/images'

# optionaly set own dir for thumbnails
THUMBNAILS_DIR = "thumbnails"

# disable caching
IMAGE_PROXY_CACHE = False

# change thumbnail format
THUMBNAILS_FORMAT = "PNG"

urls.py

urlpatterns = patterns('',
    ...
    url(r'^images/', include('image_proxy.urls')),
    ...
)

Usage

<img src="{% url 'proxy_image' '/media/anotherdjangoapp.png' %}"/>
<img src="{% url 'proxy_image_preview' '/media/anotherdjangoapp.png' %}"/>
<img src="{% url 'proxy_image_size' 'my_image_name' '100x100' %}"/>
<img src="{% url 'proxy_image_full' 'my_image_id' '100x100' 'scale' %}"/>

or
{% load thumnail %}
{% thumbnail product.image %}
{% thumbnail product.image '400x400' %}
{% thumbnail product.image '400x400' 'crop' %}

If you have clash between your favourite thumbnail provider and proxy thumbanil tags use {% load thumbnail from proxy_thumbnail %}.

Custom size and method

http://<hostname>/<path_to_source_file>/<size>/<method>/

For easily using Django Rest Framework should do this

local_settings.py

IMAGE_PROXY_URL = 'localhost:9753'

note: this url is for another django located on the address

# simple using Django Rest Framework Serializer
# for image paths return something like this
images = ["/media/image.jpg", "/media/image01.jpg"]

for image in images:

    print reverse("proxy_image", args=[image])
    /images/image/media/image.jpg # this url download image from original url and returns it !

Usage with Openstack Horizon Dashboard

Requires installed horizon.

Image in modal dialog.

<a href="{% url 'proxy_image_preview' image %}" class="ajax-modal">
  <img src="{% thumbnail product.image '100x100' 'crop' %}" class="center-block" width="100px" />
</a>

Override

from image_proxy.views import ThumbnailView

class MyThumbnailView(ThumbnailView)

    def get(self, request, *args, **kwargs):

        response = http.HttpResponse(self.image, content_type=self.content_type)

        return response

Contribution

Release History

Release History

This version
History Node

0.0.8

History Node

0.0.7

History Node

0.0.6

History Node

0.0.5

History Node

0.0.4

History Node

0.0.3

History Node

0.0.3.dev3

History Node

0.0.3.dev2

History Node

0.0.2

History Node

0.0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_image_proxy-0.0.8.tar.gz (11.3 kB) Copy SHA256 Checksum SHA256 Source Aug 3, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting