Add placeholder images
This commit is contained in:
parent
593e75a5d3
commit
3649a033b0
6 changed files with 35 additions and 39 deletions
|
|
@ -5,13 +5,11 @@ import './image.scss';
|
||||||
|
|
||||||
export const Image = ({
|
export const Image = ({
|
||||||
imageWebP,
|
imageWebP,
|
||||||
imageJpeg,
|
|
||||||
alt,
|
alt,
|
||||||
container = false,
|
container = false,
|
||||||
isIgnoredByImageViewer = false,
|
isIgnoredByImageViewer = false,
|
||||||
}: {
|
}: {
|
||||||
imageWebP: ResponsiveImage;
|
imageWebP: ResponsiveImage;
|
||||||
imageJpeg: ResponsiveImage;
|
|
||||||
alt: string;
|
alt: string;
|
||||||
container?: boolean;
|
container?: boolean;
|
||||||
isIgnoredByImageViewer?: boolean;
|
isIgnoredByImageViewer?: boolean;
|
||||||
|
|
@ -19,37 +17,31 @@ export const Image = ({
|
||||||
${
|
${
|
||||||
container
|
container
|
||||||
? `<div class="figure-container" style="padding-top:${
|
? `<div class="figure-container" style="padding-top:${
|
||||||
(imageJpeg.height / imageJpeg.width) * 100
|
(imageWebP.height / imageWebP.width) * 100
|
||||||
}%">`
|
}%">`
|
||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
<picture loading="lazy">
|
<div
|
||||||
<source
|
class="image"
|
||||||
srcset="${imageWebP.srcSet}"
|
style="background-size: cover; background-image: url('${imageWebP.placeholder}')",
|
||||||
sizes="${getSizes(imageWebP)}"
|
}}>
|
||||||
width="${imageWebP.width}"
|
<picture loading="lazy">
|
||||||
height="${imageWebP.height}"
|
<source
|
||||||
type="image/webp"
|
srcset="${imageWebP.srcSet}"
|
||||||
alt="${alt}"
|
sizes="${getSizes(imageWebP)}"
|
||||||
/>
|
type="image/webp"
|
||||||
<source
|
/>
|
||||||
srcset="${imageJpeg.srcSet}"
|
<img
|
||||||
sizes="${getSizes(imageJpeg)}"
|
${isIgnoredByImageViewer ? 'image-viewer-ignore' : ''}
|
||||||
width="${imageJpeg.width}"
|
tabindex="0"
|
||||||
height="${imageJpeg.height}"
|
loading="lazy"
|
||||||
type="image/jpeg"
|
width="${imageWebP.width}"
|
||||||
alt="${alt}"
|
height="${imageWebP.height}"
|
||||||
/>
|
src="${last(imageWebP.images)?.path}"
|
||||||
<img
|
alt="${alt}"
|
||||||
${isIgnoredByImageViewer ? 'image-viewer-ignore' : ''}
|
/>
|
||||||
tabindex="0"
|
</picture>
|
||||||
loading="lazy"
|
</div>
|
||||||
width="${imageJpeg.width}"
|
|
||||||
height="${imageJpeg.height}"
|
|
||||||
src="${last(imageJpeg.images)?.path}"
|
|
||||||
alt="${alt}"
|
|
||||||
/>
|
|
||||||
</picture>
|
|
||||||
${container ? `</div>` : ''}
|
${container ? `</div>` : ''}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
picture,
|
.image {
|
||||||
picture * {
|
|
||||||
font-size: 0;
|
font-size: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ footer#footer {
|
||||||
padding-top: var(--line-height);
|
padding-top: var(--line-height);
|
||||||
}
|
}
|
||||||
|
|
||||||
img,
|
|
||||||
svg {
|
svg {
|
||||||
@include square(var(--icon-size));
|
@include square(var(--icon-size));
|
||||||
margin-right: calc(var(--small-margin) / 2);
|
margin-right: calc(var(--small-margin) / 2);
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,12 @@
|
||||||
|
|
||||||
$img-size: 125px;
|
$img-size: 125px;
|
||||||
h1,
|
h1,
|
||||||
img,
|
.image,
|
||||||
.placeholder {
|
.placeholder {
|
||||||
@include title-font();
|
@include title-font();
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
.image {
|
||||||
@include square($img-size);
|
@include square($img-size);
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
|
|
||||||
img {
|
.image {
|
||||||
@include square($img-size);
|
@include square($img-size);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@
|
||||||
|
|
||||||
@include blurred-background();
|
@include blurred-background();
|
||||||
|
|
||||||
img,
|
.image,
|
||||||
video,
|
video,
|
||||||
iframe {
|
iframe {
|
||||||
border-radius: var(--border-radius) var(--border-radius) 0 0;
|
border-radius: var(--border-radius) var(--border-radius) 0 0;
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ noscript {
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
img,
|
.image,
|
||||||
video,
|
video,
|
||||||
iframe {
|
iframe {
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
|
|
@ -104,7 +104,7 @@ iframe {
|
||||||
transform: translate3d(0, 0, 0.00001px);
|
transform: translate3d(0, 0, 0.00001px);
|
||||||
}
|
}
|
||||||
|
|
||||||
img,
|
.image,
|
||||||
video,
|
video,
|
||||||
iframe {
|
iframe {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue