Django cloudinary 1.14.0 default_image not working
hello,
Yesterday I was trying to implement an default image handling to my django page in case if a image was deleted from the cloud. I looked at the docs here and tried to implement it on the cloudinary tag in my HTML which looks like this:
{% cloudinary post.lead_photo format="jpg" width=640 height=425 crop="fill" alt=post.title title=post.title default_image="sample.jpg" %}
When I investigated the cloudinary tag it supposed to do a image.image(**options) which should pass my default_image kwarg.
But looking at the image method I don't see that the default_image parameter handling. The result ends like this:
<img alt="my title" height="425" title="my title" width="640">
Can someone help?
-
Hi Dawid,
Apologies for the delay; it looks like this question was posted a while ago but didn't come to my attention until today.
In your example there, it doesn't appear that you're setting the public_id correctly.
The default image placeholder feature tells us to return a default if there's a problem with the requested image, but you still need to request an image first or else the SDK can't build the URL correctly (to point to the requested image and specify the other transformations, filters, etc, including the default image).
For example, a request to 12345.jpg with a default image of sample.jpg would produce a '<img src>' value like 'http://res.cloudinary.com/demo/image/upload/d_sample.jpg/12345.jpg'
Could you please take a look and see if specifying an image lets the SDK create the correct tag?0
Post is closed for comments.
Comments
1 comment