Skip to content

Commit 4891783

Browse files
authored
Merge pull request #96 from springload/chore/image-format-improvements
Image format improvements
2 parents 57cb514 + e269d58 commit 4891783

File tree

8 files changed

+41
-31
lines changed

8 files changed

+41
-31
lines changed

cdhweb/pages/templates/cdhpages/blocks/feature_block.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ <h2>{{ self.heading }}</h2>
99
{% endif %}
1010
</div>
1111

12-
{% image self.image width-750 format-webp as img_base %}
13-
{% image self.image width-1200 format-webp as img_sm %}
14-
{% image self.image width-1400 format-webp as img_md %}
12+
{% image self.image width-750 as img_base %}
13+
{% image self.image width-1200 as img_sm %}
14+
{% image self.image width-1400 as img_md %}
1515

1616
<picture class="feature__img">
1717
<source srcset="{{ img_sm.url }}" media="(min-width: 500px)">

cdhweb/pages/templates/cdhpages/blocks/image_block.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{% load wagtailcore_tags wagtailimages_tags l10n %}
22

33
{% if self.size == 'small' %}
4-
{% image self.image width-500 format-webp as img_base %}
5-
{% image self.image width-700 format-webp as img_sm %}
6-
{% image self.image width-750 format-webp as img_md %}
7-
{% image self.image width-1000 format-webp as img_xl %}
4+
{% image self.image width-500 as img_base %}
5+
{% image self.image width-700 as img_sm %}
6+
{% image self.image width-750 as img_md %}
7+
{% image self.image width-1000 as img_xl %}
88
{% elif self.size == 'medium' %}
9-
{% image self.image width-750 format-webp as img_base %}
10-
{% image self.image width-1200 format-webp as img_md %}
11-
{% image self.image width-1700 format-webp as img_xxl %}
9+
{% image self.image width-750 as img_base %}
10+
{% image self.image width-1200 as img_md %}
11+
{% image self.image width-1700 as img_xxl %}
1212
{% else %}
13-
{% image self.image width-1000 format-webp as img_base %}
14-
{% image self.image width-1500 format-webp as img_sm %}
15-
{% image self.image width-1700 format-webp as img_md %}
16-
{% image self.image width-2000 format-webp as img_xl %}
17-
{% image self.image width-2300 format-webp as img_xxxl %}
13+
{% image self.image width-1000 as img_base %}
14+
{% image self.image width-1500 as img_sm %}
15+
{% image self.image width-1700 as img_md %}
16+
{% image self.image width-2000 as img_xl %}
17+
{% image self.image width-2300 as img_xxxl %}
1818
{% endif %}
1919

2020
<figure class="sk-image sk-image--{{ self.size }}">

cdhweb/settings/components/base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,16 @@
315315
{"class": "cdhweb.pages.embed_finders.GlitchHubEmbedFinder"},
316316
]
317317

318+
WAGTAILIMAGES_WEBP_QUALITY = 80
319+
320+
WAGTAILIMAGES_FORMAT_CONVERSIONS = {
321+
"avif": "avif",
322+
"gif": "gif",
323+
"bmp": "webp",
324+
"jpeg": "webp",
325+
"png": "webp",
326+
"webp": "webp",
327+
}
318328

319329
# List of allowed tags in the rich text editor (tinyMCE). We need to add the
320330
# HTML5 <figcaption>, as it's not included by default.

templates/cdhpages/blocks/tile.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,18 @@
7272
<div class="tile__img-wrapper">
7373
{% if tile_type == 'internal_page_tile' %}
7474
{% if internal_page.specific.feed_image %}
75-
{% image internal_page.specific.feed_image fill-900x493 format-webp as image %}
75+
{% image internal_page.specific.feed_image fill-900x493 as image %}
7676
<img src="{{ image.url }}" alt="{{ image.alt }}" />
7777
{% elif internal_page.specific.hero_image %}
78-
{% image internal_page.specific.hero_image fill-900x493 format-webp as image %}
78+
{% image internal_page.specific.hero_image fill-900x493 as image %}
7979
<img src="{{ image.url }}" alt="{{ image.alt }}" />
8080
{% elif internal_page.specific.image %}
81-
{% image internal_page.specific.image fill-900x493 format-webp as image %}
81+
{% image internal_page.specific.image fill-900x493 as image %}
8282
<img src="{{ image.url }}" alt="{{ image.alt }}" />
8383
{% endif %}
8484
{% else %}
8585
{% if tile.value.image %}
86-
{% image tile.value.image fill-900x493 format-webp as image %}
86+
{% image tile.value.image fill-900x493 as image %}
8787
<img src="{{ image.url }}" alt="{{ image.alt }}" />
8888
{% endif %}
8989
{% endif %}

templates/includes/event_hero.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ <h2 class="sr-only">Speakers</h2>
6565
of via inline style.
6666
{% endcomment %}
6767

68-
{% image self.image fill-1000x563 format-webp as img_base %}
69-
{% image self.image fill-1250x703 format-webp as img_sm %}
70-
{% image self.image fill-1650x928 format-webp as img_xl %}
68+
{% image self.image fill-1000x563 as img_base %}
69+
{% image self.image fill-1250x703 as img_sm %}
70+
{% image self.image fill-1650x928 as img_xl %}
7171

7272
<picture>
7373
<source srcset="{{ img_sm.url }}" media="(min-width: 500px)">

templates/includes/person_hero.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ <h1>{{ self.title}}</h1>
5555
If changing this by image rendition, update aspect-ratio in the CSS instead
5656
of via inline style.
5757
{% endcomment %}
58-
{% image page.image fill-1000x750 format-webp as img_base %}
59-
{% image page.image fill-1250x938 format-webp as img_sm %}
60-
{% image page.image fill-1650x1238 format-webp as img_xl %}
58+
{% image page.image fill-1000x750 as img_base %}
59+
{% image page.image fill-1250x938 as img_sm %}
60+
{% image page.image fill-1650x1238 as img_xl %}
6161

6262
<picture class="person-hero__img">
6363
<source srcset="{{ img_sm.url }}" media="(min-width: 500px)">

templates/includes/project_hero.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ <h1>{{ self.title}}</h1>
3434
of via inline style.
3535
{% endcomment %}
3636

37-
{% image self.hero_image fill-1000x563 format-webp as img_base %}
38-
{% image self.hero_image fill-1250x703 format-webp as img_sm %}
39-
{% image self.hero_image fill-1650x928 format-webp as img_xl %}
37+
{% image self.hero_image fill-1000x563 as img_base %}
38+
{% image self.hero_image fill-1250x703 as img_sm %}
39+
{% image self.hero_image fill-1650x928 as img_xl %}
4040

4141
<picture class="project-hero__img">
4242
<source srcset="{{ img_sm.url }}" media="(min-width: 500px)">

templates/includes/standard_hero.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ <h1 class="standard-hero__title">{{ self.title}}</h1>
1616
of via inline style.
1717
{% endcomment %}
1818

19-
{% image self.hero_image fill-1000x563 format-webp as img_base %}
20-
{% image self.hero_image fill-1250x703 format-webp as img_sm %}
21-
{% image self.hero_image fill-1650x928 format-webp as img_xl %}
19+
{% image self.hero_image fill-1000x563 as img_base %}
20+
{% image self.hero_image fill-1250x703 as img_sm %}
21+
{% image self.hero_image fill-1650x928 as img_xl %}
2222

2323
<picture class="standard-hero__img">
2424
<source srcset="{{ img_sm.url }}" media="(min-width: 500px)">

0 commit comments

Comments
 (0)