Skip to content

Instantly share code, notes, and snippets.

@jsma
Created August 27, 2016 07:03
Show Gist options
  • Save jsma/379a82e125f1eb23a5cb01d2be0ef620 to your computer and use it in GitHub Desktop.
Save jsma/379a82e125f1eb23a5cb01d2be0ef620 to your computer and use it in GitHub Desktop.
cmsplugin_filer_image template override
{% load thumbnail filer_tags filer_image_tags %}{% spaceless %}
<figure {% if instance.image %}id="image_plugin_{{ instance.image.id }}"{% endif %}>
{% if link %}<a href="{{ link }}"{% if instance.target_blank %} target="_blank"{% endif %}>{% endif %}
{% if instance.image %}
{% if instance.use_original_image %}
<img class="img-responsive{% if instance.alignment %} {{ instance.alignment }}{% endif %}" alt="{% if instance.alt %}{{ instance.alt }}{% endif %}" src="{{ instance.image.url }}"{% if instance.width %} width="{{ instance.width }}"{% endif %}{% if instance.height %} height="{{ instance.height }}"{% endif %}{% if instance.caption %} title="{{ instance.caption }}"{% endif %} />
{% else %}
{% thumbnail instance.image size crop=opts.crop upscale=opts.upscale subject_location=opts.subject_location as thumbnail %}
<img class="img-responsive{% if instance.alignment %} {{ instance.alignment }}{% endif %}" alt="{% if instance.alt %}{{ instance.alt }}{% endif %}" src="{{ thumbnail.url }}"{% if instance.width %} width="{{ instance.width }}"{% endif %}{% if instance.height %} height="{{ instance.height }}"{% endif %}{% if instance.caption %} title="{{ instance.caption }}"{% endif %} />
{% endif %}
{% else %}
{# just a plain link to some external image #}
<img class="img-responsive{% if instance.alignment %} {{ instance.alignment }}{% endif %}" alt="{% if instance.alt %}{{ instance.alt }}{% endif %}" src="{{ instance.image_url }}"{% if size.0 %} width="{{ size.0 }}"{% endif %}{% if size.1 %} height="{{ size.1 }}"{% endif %}{% if instance.caption %} title="{{ instance.caption }}"{% endif %} />
{% endif %}
{% if link %}</a>{% endif %}
{% if instance.caption %}<figcaption>{{ instance.caption }}</figcaption>{% endif %}
{% if instance.description %}<p>{{ instance.description }}</p>{% endif %}
</figure>
{% endspaceless %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment