Skip to content

Commit

Permalink
WebP only
Browse files Browse the repository at this point in the history
  • Loading branch information
efiand committed Sep 17, 2023
1 parent 794efb4 commit 99287d7
Show file tree
Hide file tree
Showing 26 changed files with 24 additions and 41 deletions.
16 changes: 10 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions source/data/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export default () => ({
const mobileSuffix = useMobile ? '-mobile' : tabletSuffix;

return Object.assign(additions, {
default: `img/${filename}.jpg`,
default2x: `img/${filename}@2x.jpg`,
webp: `img/${filename}.webp`,
webp2x: `img/${filename}@2x.webp`,
webpTablet: `img/${filename}${tabletSuffix}.webp`,
Expand Down
Binary file removed source/img/about-video.jpg
Binary file not shown.
Binary file removed source/img/about-video@2x.jpg
Binary file not shown.
Binary file removed source/img/about.jpg
Binary file not shown.
Binary file removed source/img/about@2x.jpg
Binary file not shown.
Binary file removed source/img/avatar.jpg
Binary file not shown.
Binary file removed source/img/avatar@2x.jpg
Binary file not shown.
Binary file removed source/img/promo.jpg
Binary file not shown.
Binary file removed source/img/promo@2x.jpg
Binary file not shown.
Binary file removed source/img/supergames.jpg
Binary file not shown.
Binary file removed source/img/supergames@2x.jpg
Binary file not shown.
Binary file removed source/img/teaser.jpg
Binary file not shown.
Binary file removed source/img/teaser@2x.jpg
Binary file not shown.
Binary file removed source/img/trainer-1.jpg
Binary file not shown.
Binary file removed source/img/trainer-1@2x.jpg
Binary file not shown.
Binary file removed source/img/trainer-2.jpg
Binary file not shown.
Binary file removed source/img/trainer-2@2x.jpg
Binary file not shown.
Binary file removed source/img/trainer-3.jpg
Binary file not shown.
Binary file removed source/img/trainer-3@2x.jpg
Binary file not shown.
Binary file removed source/img/trainer-4.jpg
Binary file not shown.
Binary file removed source/img/trainer-4@2x.jpg
Binary file not shown.
Binary file removed source/img/wheels.png
Binary file not shown.
Binary file removed source/img/wheels@2x.png
Binary file not shown.
13 changes: 2 additions & 11 deletions source/layouts/components/picture.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,21 @@
<picture>
{% if webpMobile %}
<source
type="image/webp"
media="(max-width: 320px)"
srcset="{{ webpMobile }} 1x{{ webpMobile2x ? ', ' ~ webpMobile2x ~ ' 2x' }}"
/>
{% endif %}
{% if webpTablet %}
<source
type="image/webp"
media="(max-width: 1199px)"
srcset="{{ webpTablet }} 1x{{ webpTablet2x ? ', ' ~ webpTablet2x ~ ' 2x' }}"
/>
{% endif %}
{% if webp %}
<source
type="image/webp"
{{ webpTablet or webpMobile ? 'media="(min-width: 1200px)"' }}
srcset="{{ webp }} 1x{{ webp2x ? ', ' ~ webp2x ~ ' 2x' }}"
/>
{% endif %}

<img
{{ className ? 'class="' ~ className ~ '"' }}
src="{{ default }}"
{{ default2x ? 'srcset="' ~ default2x ~ ' 2x"' }}
src="{{ webp }}"
{{ webp2x ? 'srcset="' ~ webp2x ~ ' 2x"' }}
alt="{{ alt }}"
{{ not alt ? 'aria-hidden="true"' }}
{{ not immediately ? 'loading="lazy"' }}
Expand Down
34 changes: 12 additions & 22 deletions source/sass/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,27 @@
}

@mixin background-image() {
@supports (background-image: var(--bg-webp)) {
@media (min-width: $vp-1024) {
background-image: var(--bg-webp);
@media (min-width: $vp-1024) {
background-image: var(--bg-webp);

@include retina {
background-image: var(--bg-webp2x, none);
}
}

@include vp-1199 {
background-image: var(--bg-webpTablet, none);

@include retina {
background-image: var(--bg-webpTablet2x, none);
}
@include retina {
background-image: var(--bg-webp2x, none);
}
}

@include vp-767 {
background-image: var(--bg-webpMobile, none);
@include vp-1199 {
background-image: var(--bg-webpTablet, none);

@include retina {
background-image: var(--bg-webpMobile2x, none);
}
@include retina {
background-image: var(--bg-webpTablet2x, none);
}
}

@supports not (background-image: var(--bg-webp, none)) {
background-image: var(--bg-default, none);
@include vp-767 {
background-image: var(--bg-webpMobile, none);

@include retina {
background-image: var(--bg-default2x, none);
background-image: var(--bg-webpMobile2x, none);
}
}
}
Expand Down

0 comments on commit 99287d7

Please sign in to comment.