Skip to content

Commit

Permalink
pixelate if < 256x256
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Jul 14, 2024
1 parent 71f1934 commit 3a1aae0
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/listing.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@
video {
pointer-events: none;
}
.pixelated {
image-rendering: pixelated;
image-rendering: crisp-edges;
}
.behind {
position: absolute;
}
Expand Down Expand Up @@ -450,15 +454,29 @@ <h1><a href="/">~</a>{linked-path}</h1>
}

function makeImage({name, href, date, size}) {
return createElem('a', {
className: 'thumbnail',
href,
title: name,
style: {
backgroundImage: `url(${href})`,
},
return createElem('div', {
className: 'thumbnail'
}, [
createElem('span', { style: { display: 'none', textContent: name }}),
createElem('a', {
className: 'behind thumbnail',
textContent: name,
href,
}),
createElem('img', {
className: 'thumbnail',
src: href,
alt: name,
onLoad: function() {
if (this.naturalWidth < 256 && this.naturalHeight < 256) {
this.classList.add('pixelated');
}
},
}),
createElem('a', {
className: 'front',
href,
title: name,
}),
]);
}

Expand Down

0 comments on commit 3a1aae0

Please sign in to comment.