Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improved album covers #1944

Merged
merged 2 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/autoload/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@
'height' => 1920,
],
'album_cover' => [
'width' => 320,
'height' => 180,
'width' => 640,
'height' => 360,
'inner_border' => 2,
'outer_border' => 0,
'cols' => 2,
Expand Down
2 changes: 2 additions & 0 deletions module/Photo/src/Controller/AlbumAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public function yearAction(): ViewModel

return new ViewModel([
'albums' => $this->albumService->getAlbumsByYear($year, false),
'config' => $this->photoConfig,
'years' => $this->albumService->getAlbumYears(false),
'year' => $year,
]);
Expand All @@ -122,6 +123,7 @@ public function undatedAction(): ViewModel

return new ViewModel([
'albums' => $this->albumService->getAlbumsWithoutDate(),
'config' => $this->photoConfig,
'years' => $this->albumService->getAlbumYears(false),
]);
}
Expand Down
2 changes: 2 additions & 0 deletions module/Photo/src/Controller/PhotoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function indexAction(): ViewModel
'years' => $years,
'year' => $year,
'albums' => $this->filterAlbums($this->albumService->getAlbumsByYear($year)),
'config' => $this->photoConfig,
],
);
}
Expand Down Expand Up @@ -99,6 +100,7 @@ public function searchAction(): ViewModel
'result' => $groupedAlbums,
'prompt' => $form->getData()['query'],
'form' => $form,
'config' => $this->photoConfig,
],
);
}
Expand Down
2 changes: 1 addition & 1 deletion module/Photo/src/Service/AlbumCover.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ protected function drawComposition(
array $images,
): void {
$innerBorder = $this->photoConfig['album_cover']['inner_border'];
$outerBorder = $this->photoConfig['album_cover']['inner_border'];
$outerBorder = $this->photoConfig['album_cover']['outer_border'];

//calculate the total size of all images inside the outer border
$innerWidth = $this->photoConfig['album_cover']['width'] - 2 * $outerBorder;
Expand Down
12 changes: 10 additions & 2 deletions module/Photo/view/partial/album-card.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ use Photo\Model\Album as AlbumModel;

/**
* @var PhpRenderer|HelperTrait $this
* @var bool $admin
* @var bool|null $admin
* @var AlbumModel $album
* @var array $config
* @var string|null $prompt
*/

$admin = isset($admin) && $admin;
Expand All @@ -24,7 +26,13 @@ $lastWeek = (new DateTime('now'))->sub(new DateInterval('P7D'));
<div class="card">
<a class="stretched-link" href="<?= $this->url($url, ['album_id' => $album->getId(), 'album_type' => 'album']) ?>"></a>
<?php if (null !== ($albumCover = $album->getCoverPath())): ?>
<img class="card-image" src="<?= $this->fileUrl($albumCover) ?>" alt="">
<?php
$albumCoverSize = [
'w' => $config['album_cover']['width'],
'h' => $config['album_cover']['height'],
];
?>
<img class="card-image" src="<?= $this->glideUrl()->getUrl($albumCover, $albumCoverSize) ?>" alt="">
<?php else: ?>
<img class="card-image" src="/img/missing_cover.svg" alt="">
<?php endif; ?>
Expand Down
3 changes: 2 additions & 1 deletion module/Photo/view/partial/albums.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use Photo\Model\Album as AlbumModel;
* @var PhpRenderer|HelperTrait $this
* @var bool|null $admin
* @var AlbumModel[] $albums
* @var array $config
* @var string|null $prompt
*/

Expand All @@ -19,7 +20,7 @@ $prompt = $prompt ?? null;
<div class="card-grid <?= $admin ? 'admin-grid' : '' ?>">
<?php foreach ($albums as $album): ?>
<?php if ($album->getPhotoCount() > 0 || $admin): ?>
<?= $this->partial('partial/album-card.phtml', ['album' => $album, 'admin' => $admin, 'prompt' => $prompt]) ?>
<?= $this->partial('partial/album-card.phtml', ['album' => $album, 'admin' => $admin, 'config' => $config, 'prompt' => $prompt]) ?>
<?php endif; ?>
<?php endforeach; ?>
</div>
3 changes: 2 additions & 1 deletion module/Photo/view/photo/album-admin/undated.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use Photo\Model\Album as AlbumModel;
/**
* @var PhpRenderer|HelperTrait $this
* @var AlbumModel[] $albums
* @var array $config
* @var int[] $years
*/

Expand All @@ -19,7 +20,7 @@ $this->breadcrumbs()
<?= $this->partial('partial/years', ['years' => $years, 'admin' => true]) ?>
<br>
<?php if (0 !== count($albums)): ?>
<?= $this->partial('partial/albums', ['albums' => $albums, 'admin' => true]) ?>
<?= $this->partial('partial/albums', ['albums' => $albums, 'admin' => true, 'config' => $config]) ?>
<?php else: ?>
<div class="row">
<div class="col-md-12">
Expand Down
2 changes: 1 addition & 1 deletion module/Photo/view/photo/album-admin/view.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ $this->breadcrumbs()
</div>
<br>
<?php if (0 !== $album->getChildren()->count()): ?>
<?= $this->partial('partial/albums', ['albums' => $album->getChildren(), 'admin' => true]) ?>
<?= $this->partial('partial/albums', ['albums' => $album->getChildren(), 'admin' => true, 'config' => $config]) ?>
<?php endif; ?>
<div class="row">
<div class="col-md-12">
Expand Down
3 changes: 2 additions & 1 deletion module/Photo/view/photo/album-admin/year.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use Photo\Model\Album as AlbumModel;
* @var PhpRenderer|HelperTrait $this
* @var AlbumModel[] $albums
* @var int[] $years
* @var array $config
* @var int $year
*/

Expand All @@ -20,7 +21,7 @@ $this->breadcrumbs()
<?= $this->partial('partial/years', ['years' => $years, 'year' => $year, 'admin' => true]) ?>
<br>
<?php if (0 !== count($albums)): ?>
<?= $this->partial('partial/albums', ['albums' => $albums, 'admin' => true]) ?>
<?= $this->partial('partial/albums', ['albums' => $albums, 'admin' => true, 'config' => $config]) ?>
<?php else: ?>
<div class="row">
<div class="col-md-12">
Expand Down
2 changes: 1 addition & 1 deletion module/Photo/view/photo/album/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ $this->scriptUrl()->requireUrl('member/search')
):
$shownAlbums++;
?>
<?= $this->partial('partial/album-card.phtml', ['album' => $item]) ?>
<?= $this->partial('partial/album-card.phtml', ['album' => $item, 'config' => $config]) ?>
<?php endif; ?>
<?php endforeach ?>
</div>
Expand Down
3 changes: 2 additions & 1 deletion module/Photo/view/photo/photo/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use Photo\Model\Album as AlbumModel;
/**
* @var PhpRenderer|HelperTrait $this
* @var AlbumModel $albums
* @var array $config
* @var array $years
* @var int $year
*/
Expand All @@ -21,7 +22,7 @@ $this->headTitle($this->translate('Photos'));
<?= $this->partial('partial/years', ['years' => $years, 'year' => $year]) ?>
<br>
<?php if (0 !== count($albums)): ?>
<?= $this->partial('partial/albums', ['albums' => $albums]) ?>
<?= $this->partial('partial/albums', ['albums' => $albums, 'config' => $config]) ?>
<?php else: ?>
<div class="row">
<div class="col-md-12">
Expand Down
3 changes: 2 additions & 1 deletion module/Photo/view/photo/photo/search.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use Photo\Model\Album as AlbumModel;
* @var SearchAlbumForm $form
* @var array<int, AlbumModel[]>|null $result
* @var string|null $prompt
* @var array|null $config
*/

$this->headTitle($this->translate('Search Albums'));
Expand Down Expand Up @@ -68,7 +69,7 @@ $this->headTitle($this->translate('Search Albums'));
<h3>
<?= sprintf('%d/%d', $year, $year + 1)?>
</h3>
<?= $this->partial('partial/albums', ['albums' => $albums, 'prompt' => $prompt]) ?>
<?= $this->partial('partial/albums', ['albums' => $albums, 'prompt' => $prompt, 'config' => $config]) ?>
<hr>
</div>
<?php endforeach; ?>
Expand Down
2 changes: 1 addition & 1 deletion public/css/gewis-theme.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions resources/scss/modules/_photo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,7 @@ Photo
cursor: pointer;
}
}

.cover-preview {
max-width: 100%;
}
Loading