Implemented a page to view a larger preview of a photo

This commit is contained in:
Andy Heathershaw 2016-09-05 14:27:20 +01:00
parent bb6e77191e
commit ef95fd31ba
6 changed files with 88 additions and 6 deletions

View File

@ -95,20 +95,20 @@ class AlbumController extends Controller
return Theme::render('admin.edit_album', ['album' => $album]); return Theme::render('admin.edit_album', ['album' => $album]);
} }
public function monitorUpload($id, $upload_id) public function monitorUpload($id, $uploadId)
{ {
$this->authorize('admin-access'); $this->authorize('admin-access');
$upload = AlbumController::loadUpload($upload_id, $id); $upload = AlbumController::loadUpload($uploadId, $id);
return Theme::render('admin.album_upload_progress', ['upload' => $upload, 'album' => $upload->album]); return Theme::render('admin.album_upload_progress', ['upload' => $upload, 'album' => $upload->album]);
} }
public function monitorUploadJson($id, $upload_id) public function monitorUploadJson($id, $uploadId)
{ {
$this->authorize('admin-access'); $this->authorize('admin-access');
return response()->json(AlbumController::loadUpload($upload_id, $id)->toArray()); return response()->json(AlbumController::loadUpload($uploadId, $id)->toArray());
} }
/** /**

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers\Gallery; namespace App\Http\Controllers\Gallery;
use App\Album; use App\Album;
use App\Facade\Theme;
use app\Http\Controllers\Admin\AlbumController; use app\Http\Controllers\Admin\AlbumController;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Photo; use App\Photo;
@ -22,6 +23,17 @@ class PhotoController extends Controller
return response()->file($albumSource->getPathToPhoto($album, $photo, $thumbnail)); return response()->file($albumSource->getPathToPhoto($album, $photo, $thumbnail));
} }
public function show($albumUrlAlias, $photoFilename)
{
$album = PhotoController::loadAlbumByAlias($albumUrlAlias);
$photo = PhotoController::loadPhotoByAlbumAndFilename($album, $photoFilename);
return Theme::render('gallery.photo', [
'album' => $album,
'photo' => $photo
]);
}
/** /**
* @param $id * @param $id
* @return Album * @return Album

View File

@ -43,7 +43,7 @@ class Photo extends Model
return $this->belongsTo(Album::class); return $this->belongsTo(Album::class);
} }
public function thumbnailUrl($thumbnailName) public function thumbnailUrl($thumbnailName = null)
{ {
/** @var Album $album */ /** @var Album $album */
//$album = Album::where('id', $this->album_id)->first(); //$album = Album::where('id', $this->album_id)->first();

View File

@ -23,6 +23,11 @@
margin-bottom: 0; margin-bottom: 0;
} }
.photo-metadata .metadata_name
{
font-weight: bold;
}
.tab-content { .tab-content {
border: solid 1px #ddd; border: solid 1px #ddd;
border-top: 0; border-top: 0;

View File

@ -0,0 +1,65 @@
@extends('themes.base.layout')
@section('title', 'Welcome')
@section('content')
<div class="container">
<div class="row">
<div class="col-xs-12">
<h1>{{ $photo->name }}</h1>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-8">
<a href="{{ $photo->thumbnailUrl() }}"><img src="{{ $photo->thumbnailUrl('fullsize') }}" alt="" class="img-thumbnail"/></a>
</div>
<div class="col-xs-12 col-sm-4">
<p>Information about this photo:</p>
<table class="table table-striped photo-metadata">
<thead>
<tr>
<th>Name</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td class="metadata_name">File name:</td>
<td class="metadata_value">{{ $photo->name }}</td>
</tr>
@if (strlen($photo->taken_at) > 0)
<tr>
<td class="metadata_name">Date taken:</td>
<td class="metadata_value">{{ $photo->taken_at }}</td>
</tr>
@endif
@if (strlen($photo->camera_make) > 0)
<tr>
<td class="metadata_name">Camera make:</td>
<td class="metadata_value">{{ $photo->camera_make }}</td>
</tr>
@endif
@if (strlen($photo->camera_model) > 0)
<tr>
<td class="metadata_name">Camera model:</td>
<td class="metadata_value">{{ $photo->camera_model }}</td>
</tr>
@endif
@if (strlen($photo->camera_software) > 0)
<tr>
<td class="metadata_name">Camera software:</td>
<td class="metadata_value">{{ $photo->camera_software }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
@endsection

View File

@ -31,5 +31,5 @@ Route::group(['prefix' => 'admin'], function () {
// Gallery // Gallery
Route::get('/', 'Gallery\DefaultController@index')->name('home'); Route::get('/', 'Gallery\DefaultController@index')->name('home');
Route::get('/{albumUrlAlias}', 'Gallery\AlbumController@index')->name('viewAlbum'); Route::get('/{albumUrlAlias}', 'Gallery\AlbumController@index')->name('viewAlbum');
Route::get('/{albumUrlAlias}/{photoFilename}', 'Gallery\PhotoController@view')->name('viewPhoto'); Route::get('/{albumUrlAlias}/{photoFilename}', 'Gallery\PhotoController@show')->name('viewPhoto');
Route::get('/photo/{albumUrlAlias}/{photoFilename}', 'Gallery\PhotoController@download')->name('downloadPhoto'); Route::get('/photo/{albumUrlAlias}/{photoFilename}', 'Gallery\PhotoController@download')->name('downloadPhoto');