#32: Added next/previous buttons to the individual photo page
This commit is contained in:
parent
365ea689ef
commit
7bfc829931
@ -102,12 +102,17 @@ class PhotoController extends Controller
|
||||
|
||||
$isOriginalAllowed = Gate::forUser($this->getUser())->allows('photo.download_original', $photo);
|
||||
|
||||
$returnAlbumUrl = $album->url();
|
||||
$referer = $request->headers->get('Referer');
|
||||
if (strlen($referer) > 0 && MiscHelper::isSafeUrl($referer))
|
||||
{
|
||||
$returnAlbumUrl = $referer;
|
||||
}
|
||||
// Load the Next/Previous buttons
|
||||
$thisPhotoDate = is_null($photo->taken_at) ? $photo->created_at : $photo->taken_at;
|
||||
|
||||
$previousPhoto = $album->photos()
|
||||
->where(DB::raw('COALESCE(taken_at, created_at)'), '<', $thisPhotoDate)
|
||||
->orderBy(DB::raw('COALESCE(taken_at, created_at)'), 'desc')
|
||||
->first();
|
||||
$nextPhoto = $album->photos()
|
||||
->where(DB::raw('COALESCE(taken_at, created_at)'), '>', $thisPhotoDate)
|
||||
->orderBy(DB::raw('COALESCE(taken_at, created_at)'))
|
||||
->first();
|
||||
|
||||
// Record the visit to the photo
|
||||
if (UserConfig::get('enable_visitor_hits'))
|
||||
@ -124,8 +129,9 @@ class PhotoController extends Controller
|
||||
return Theme::render('gallery.photo', [
|
||||
'album' => $album,
|
||||
'is_original_allowed' => $isOriginalAllowed,
|
||||
'next_photo' => $nextPhoto,
|
||||
'photo' => $photo,
|
||||
'return_album_url' => $returnAlbumUrl
|
||||
'previous_photo' => $previousPhoto
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -17,10 +17,12 @@ return [
|
||||
'labels_title' => 'Labels',
|
||||
'manage_album_link' => 'Manage',
|
||||
'manage_album_link_2' => 'Manage Album',
|
||||
'next_button' => 'Next Photo »',
|
||||
'open_album_link' => 'Open Album',
|
||||
'other_albums_description' => 'You may also be interested in the following albums.',
|
||||
'other_albums_heading' => 'More Albums in :album_name',
|
||||
'photos' => 'photo|photos',
|
||||
'previous_button' => '« Previous Photo',
|
||||
'show_more_labels' => '... and :count other|... and :count others',
|
||||
'statistics' => [
|
||||
'album_by_photos' => 'Top 10 largest albums - number of photos',
|
||||
|
@ -4,11 +4,7 @@
|
||||
@section('breadcrumb')
|
||||
<li class="breadcrumb-item"><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li>
|
||||
@foreach ($album->albumParentTree() as $parentAlbum)
|
||||
@if ($parentAlbum->id == $photo->album->id)
|
||||
<li class="breadcrumb-item"><a href="{{ $return_album_url }}">{{ $photo->album->name }}</a></li>
|
||||
@else
|
||||
<li class="breadcrumb-item"><a href="{{ $parentAlbum->url() }}">{{ $parentAlbum->name }}</a></li>
|
||||
@endif
|
||||
<li class="breadcrumb-item"><a href="{{ $parentAlbum->url() }}">{{ $parentAlbum->name }}</a></li>
|
||||
@endforeach
|
||||
<li class="breadcrumb-item active">{{ $photo->name }}</li>
|
||||
@endsection
|
||||
@ -34,6 +30,19 @@
|
||||
</a>
|
||||
@endif
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-6">
|
||||
@if (!is_null($previous_photo))
|
||||
<a href="{{ $previous_photo->url() }}" class="btn btn-secondary">@lang('gallery.previous_button')</a>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-6 text-right">
|
||||
@if (!is_null($next_photo))
|
||||
<a href="{{ $next_photo->url() }}" class="btn btn-secondary">@lang('gallery.next_button')</a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if ($photo->labels()->count() > 0)
|
||||
<h4>@lang('gallery.labels')</h4>
|
||||
<ul class="nav nav-pills mb-4">
|
||||
@ -101,7 +110,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col mt-4">
|
||||
<a href="{{ $return_album_url }}" class="btn btn-secondary">« @lang('gallery.back_to_album', ['name' => $photo->album->name])</a>
|
||||
<a href="{{ $album->url() }}" class="btn btn-secondary">« @lang('gallery.back_to_album', ['name' => $photo->album->name])</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user