0
votes

It doesn't look like this exists, but does Cloudinary Django template tag library include Cloudinary.responsive image features?

Cloudinary has 'response jquery' library that is used as follows:

<img data-src="http://res.cloudinary.com/demo/image/upload/w_auto/smiling_man.jpg" class="cld-responsive">

But is there also an equivalent Cloudinary Django template tag way to use Cloudinary.responsive? Perhaps something along lines of:

{% load cloudinary %}
{% cloudinary_includes %}
{% cloudinary_js_config %}

{% cloudinary.responsive photo.filename auto-width=600 %}

I haven't found anything yet so answer is probably no, unless it is very new or not yet discussed.

The alternative will be building the Cloudinary.responsive img tag in the Django template like this:

<img data-src="http://res.cloudinary.com/demo/image/upload/w_auto/{{ photo.filename }}" class="cld-responsive">

This will require a bit of work as the uploaded file is stored in my Django model as:

 image/upload/v1444896521/ttme5v9ejttfbtpaojyk.jpg

So i will have parse that to get the Cloudinary responsive 'w_auto' string into the url.

I also want to have a 'max-width' on the image as well as being responsive. Not sure how to make that happen. Any ideas appreciated.

Also maybe there are other jquery solutions i might not know about to get cloudinary responsive images in Django ?

Thanks

1

1 Answers

0
votes

Actually the responsive URLs (w_auto) is indeed supported via the Django SDK. See the following for reference: https://github.com/cloudinary/pycloudinary/blob/002dfd3db5c9890f8876cd3a35416edfd3ed24ea/tests/image_test.py#L36