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