-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use img tag in hero picture template
This allows using source filetypes
- Loading branch information
Showing
2 changed files
with
29 additions
and
32 deletions.
There are no files selected for viewing
45 changes: 17 additions & 28 deletions
45
fragdenstaat_de/templates/djangocms_picture/hero/picture.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,22 @@ | ||
{% load cms_tags %} | ||
{% load thumbnail %} | ||
{% load fds_cms_tags %} | ||
|
||
<style> | ||
#hero-image-{{ instance.pk }} { | ||
background-image: url('{% thumbnail instance.picture 450x450 crop subject_location=instance.picture.subject_location %}'); | ||
} | ||
@media(min-width:576px){ | ||
#hero-image-{{ instance.pk }} { | ||
background-image: url('{% thumbnail instance.picture 768x400 crop subject_location=instance.picture.subject_location %}'); | ||
} | ||
} | ||
@media(min-width:768px){ | ||
#hero-image-{{ instance.pk }} { | ||
background-image: url('{% thumbnail instance.picture 992x400 crop subject_location=instance.picture.subject_location %}'); | ||
} | ||
} | ||
@media(min-width:992px){ | ||
#hero-image-{{ instance.pk }} { | ||
background-image: url('{% thumbnail instance.picture 1200x400 crop subject_location=instance.picture.subject_location %}'); | ||
} | ||
} | ||
@media(min-width:1200px){ | ||
#hero-image-{{ instance.pk }} { | ||
background-image: url('{% thumbnail instance.picture 1920x400 crop subject_location=instance.picture.subject_location %}'); | ||
} | ||
} | ||
</style> | ||
<div class="hero-image{% if instance.attributes.class %} {{ instance.attributes.class }}{% endif %}" id="hero-image-{{ instance.pk }}" {{ instance.attributes_str }}> | ||
<div class="hero-image{% if instance.attributes.class %} {{ instance.attributes.class }}{% endif %}" {{ instance.attributes_str }}> | ||
{% with picture=instance.picture %} | ||
{% get_responsive_filer_image picture "col-12" as respimg %} | ||
<picture> | ||
{% for source in respimg.sources %} | ||
<source | ||
srcset="{{ source.srcset }}" | ||
sizes="{{ respimg.sizes }}" | ||
type="{{ source.mime_type }}" | ||
/> | ||
{% endfor %} | ||
|
||
<img class="hero-image-img" loading="lazy" width="{{ picture.width|floatformat:"0u" }}" height="{{ picture.height|floatformat:"0u" }}" src="{{ respimg.src }}" srcset="{{ respimg.srcset }}" sizes="{{ respimg.sizes }}" alt=""> | ||
</picture> | ||
{% endwith %} | ||
{% for plugin in instance.child_plugin_instances %} | ||
{% render_plugin plugin %} | ||
{% endfor %} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters