PhotosIndex: add blurred versions of thumbnails for added coolness

This commit is contained in:
Aaron van Geffen 2023-11-10 21:57:23 +01:00
parent 238dc1d6e7
commit a69c987510
2 changed files with 47 additions and 17 deletions

View File

@ -199,33 +199,57 @@ i.space-invader.alt-7::before {
div.polaroid {
background: #fff;
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.3);
line-height: 0;
position: relative;
transition: 0.25s;
}
div.polaroid img {
background: url('../images/nothumb.svg') center no-repeat;
div.polaroid:hover {
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.5);
}
div.polaroid img.normal-photo {
background: #fff url('../images/nothumb.svg') center no-repeat;
border: none;
left: 0;
object-fit: cover;
position: absolute;
top: 0;
width: 100%;
z-index: 20;
}
div.polaroid img.blur-photo {
filter: blur(50px);
left: 0;
object-fit: cover;
position: absolute;
top: 0;
width: 100%;
z-index: 0;
}
div.polaroid img.placeholder-image {
background: #fff;
z-index: 20;
}
div.polaroid h4 {
background: #fff;
bottom: 0;
color: #000;
margin: 0;
font: 400 18px 'Coda', sans-serif;
padding: 15px 5px;
position: absolute;
text-overflow: ellipsis;
text-align: center;
width: 100%;
white-space: nowrap;
overflow: hidden;
z-index: 20;
}
div.polaroid a {
display: block;
text-decoration: none;
}
div.polaroid:hover {
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}
/* Album title boxes

View File

@ -83,27 +83,33 @@ class PhotosIndex extends Template
protected function photo(Image $image, $className, $width, $height, $crop = true, $fit = true)
{
// Prefer thumbnail aspect ratio if available, otherwise use image aspect ratio.
$aspectRatio = isset($width, $height) ? $width / $height : $image->ratio();
echo '
<div class="polaroid ', $className, '">';
<div class="polaroid ', $className, '" style="aspect-ratio: ', $aspectRatio, '">';
if ($this->show_edit_buttons)
echo '
<a class="edit" href="', BASEURL, '/editasset/?id=', $image->getId(), '">Edit</a>';
echo '
<a href="', $image->getPageUrl(), $this->url_suffix, '#photo_frame">
<a href="', $image->getPageUrl(), $this->url_suffix, '#photo_frame">';
foreach (['normal-photo', 'blur-photo'] as $className)
{
echo '
<img src="', $image->getThumbnailUrl($width, $height, $crop, $fit), '"';
// Can we offer double-density thumbs?
if ($image->width() >= $width * 2 && $image->height() >= $height * 2)
echo ' srcset="', $image->getThumbnailUrl($width * 2, $height * 2, $crop, $fit), ' 2x"';
else
echo ' srcset="', $image->getThumbnailUrl($image->width(), $image->height(), true), ' 2x"';
// Can we offer double-density thumbs?
if ($image->width() >= $width * 2 && $image->height() >= $height * 2)
echo ' srcset="', $image->getThumbnailUrl($width * 2, $height * 2, $crop, $fit), ' 2x"';
else
echo ' srcset="', $image->getThumbnailUrl($image->width(), $image->height(), true), ' 2x"';
// Prefer thumbnail aspect ratio if available, otherwise use image aspect ratio.
$aspectRatio = isset($width, $height) ? $width / $height : $image->ratio();
echo ' alt="" title="', $image->getTitle(), '" style="aspect-ratio: ', $aspectRatio, '">';
echo ' alt="" title="', $image->getTitle(), '" class="', $className, '" style="aspect-ratio: ', $aspectRatio, '">';
}
if ($this->show_labels)
echo '