I am successfully creating a Cloudinary image as follows:
{% cloudinary photo.filename
width='300'
crop='fill'
class='item_photo'
id=photo.filename %}
Which results in html img tag:
<img
class="item_photo"
id="xxxxxx"
width="300"
src="https://res.cloudinary.com/xxx/image/upload/c_fill,w_300/vxxx/xxx.jpg">
However, I want to add an onClick event to the img, but am not able to figure out the correct syntax or perhaps even if it is possible.
I would like html tag to look like:
<img
class="item_photo"
id="xxxxxx"
width="300"
onClick=imageClick('xxxxxx') <=== event variable is same as `id` value
src="https://res.cloudinary.com/xxx/image/upload/c_fill,w_300/vxxx/xxx.jpg">
The id and imageClick variable are themselves populated by Django template tag value photo.filename.
Some things I've tried:
onClick='photoClick(photo.filename)' %}
{% with add:'onClick=photoClick('{{ photo.filename }}|add:') as onclick %}{{ onclick }}{% endwith %}
|add:'onClick=photoClick('{{ photo.filename }}|add:')' %}
How can I construct the onClick=photoClick(xxx) part of this template tag?