Added a separate storage_file_name column to the Photo class
This commit is contained in:
parent
484f5d8fb2
commit
626cd5b2ec
@ -32,14 +32,14 @@ class LocalFilesystemSource implements IAlbumSource
|
|||||||
$thumbnail = $this->getOriginalsFolder();
|
$thumbnail = $this->getOriginalsFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprintf('%s/%s/%s', $this->getPathToAlbum($album), $thumbnail, $photo->file_name);
|
return sprintf('%s/%s/%s', $this->getPathToAlbum($album), $thumbnail, $photo->storage_file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUrlToPhoto(Album $album, Photo $photo, $thumbnail = null)
|
public function getUrlToPhoto(Album $album, Photo $photo, $thumbnail = null)
|
||||||
{
|
{
|
||||||
$photoUrl = route('downloadPhoto', [
|
$photoUrl = route('downloadPhoto', [
|
||||||
'albumUrlAlias' => $album->url_alias,
|
'albumUrlAlias' => $album->url_alias,
|
||||||
'photoFilename' => $photo->file_name
|
'photoFilename' => $photo->storage_file_name
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!is_null($thumbnail))
|
if (!is_null($thumbnail))
|
||||||
@ -53,7 +53,7 @@ class LocalFilesystemSource implements IAlbumSource
|
|||||||
public function saveThumbnail(Album $album, Photo $photo, $thumbnailInfo, $tempFilename)
|
public function saveThumbnail(Album $album, Photo $photo, $thumbnailInfo, $tempFilename)
|
||||||
{
|
{
|
||||||
$fileInfo = new File($tempFilename);
|
$fileInfo = new File($tempFilename);
|
||||||
$fileInfo->move(sprintf('%s/%s', $this->getPathToAlbum($album), $thumbnailInfo['name']), $photo->file_name);
|
$fileInfo->move(sprintf('%s/%s', $this->getPathToAlbum($album), $thumbnailInfo['name']), $photo->storage_file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveUploadedPhoto(Album $album, File $uploadedFile)
|
public function saveUploadedPhoto(Album $album, File $uploadedFile)
|
||||||
|
@ -66,8 +66,9 @@ class PhotoController extends Controller
|
|||||||
|
|
||||||
$photo = new Photo();
|
$photo = new Photo();
|
||||||
$photo->album_id = $album->id;
|
$photo->album_id = $album->id;
|
||||||
$photo->name = $photoFile->getClientOriginalName();
|
$photo->name = pathinfo($photoFile->getClientOriginalName(), PATHINFO_FILENAME);
|
||||||
$photo->file_name = $savedFile->getFilename();
|
$photo->file_name = $photoFile->getClientOriginalName();
|
||||||
|
$photo->storage_file_name = $savedFile->getFilename();
|
||||||
$photo->mime_type = $savedFile->getMimeType();
|
$photo->mime_type = $savedFile->getMimeType();
|
||||||
$photo->file_size = $savedFile->getSize();
|
$photo->file_size = $savedFile->getSize();
|
||||||
$photo->save();
|
$photo->save();
|
||||||
@ -143,8 +144,9 @@ class PhotoController extends Controller
|
|||||||
|
|
||||||
$photo = new Photo();
|
$photo = new Photo();
|
||||||
$photo->album_id = $album->id;
|
$photo->album_id = $album->id;
|
||||||
$photo->name = $photoFile->getFilename();
|
$photo->name = pathinfo($photoFile->getFilename(), PATHINFO_FILENAME);
|
||||||
$photo->file_name = $savedFile->getFilename();
|
$photo->file_name = $photoFile->getFilename();
|
||||||
|
$photo->storage_file_name = $savedFile->getFilename();
|
||||||
$photo->mime_type = $savedFile->getMimeType();
|
$photo->mime_type = $savedFile->getMimeType();
|
||||||
$photo->file_size = $savedFile->getSize();
|
$photo->file_size = $savedFile->getSize();
|
||||||
$photo->save();
|
$photo->save();
|
||||||
|
@ -58,7 +58,7 @@ class PhotoController extends Controller
|
|||||||
{
|
{
|
||||||
$photo = Photo::where([
|
$photo = Photo::where([
|
||||||
['album_id', $album->id],
|
['album_id', $album->id],
|
||||||
['file_name', $filename]
|
['storage_file_name', $filename]
|
||||||
])->first();
|
])->first();
|
||||||
|
|
||||||
if (is_null($photo))
|
if (is_null($photo))
|
||||||
|
@ -19,6 +19,7 @@ class Photo extends Model
|
|||||||
'name',
|
'name',
|
||||||
'description',
|
'description',
|
||||||
'file_name',
|
'file_name',
|
||||||
|
'storage_file_name',
|
||||||
'mime_type',
|
'mime_type',
|
||||||
'file_size',
|
'file_size',
|
||||||
'metadata_version',
|
'metadata_version',
|
||||||
@ -46,9 +47,7 @@ class Photo extends Model
|
|||||||
public function thumbnailUrl($thumbnailName = null)
|
public function thumbnailUrl($thumbnailName = null)
|
||||||
{
|
{
|
||||||
/** @var Album $album */
|
/** @var Album $album */
|
||||||
//$album = Album::where('id', $this->album_id)->first();
|
|
||||||
$album = $this->album;
|
$album = $this->album;
|
||||||
$albumSource = $album->getAlbumSource();
|
|
||||||
|
|
||||||
return $album->getAlbumSource()->getUrlToPhoto($album, $this, $thumbnailName);
|
return $album->getAlbumSource()->getUrlToPhoto($album, $this, $thumbnailName);
|
||||||
}
|
}
|
||||||
@ -57,7 +56,7 @@ class Photo extends Model
|
|||||||
{
|
{
|
||||||
return route('viewPhoto', [
|
return route('viewPhoto', [
|
||||||
'albumUrlAlias' => $this->album->url_alias,
|
'albumUrlAlias' => $this->album->url_alias,
|
||||||
'photoFilename' => $this->file_name
|
'photoFilename' => $this->storage_file_name
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddPhotoStorageFileColumn extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('photos', function (Blueprint $table) {
|
||||||
|
$table->string('storage_file_name');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('photos', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('storage_file_name');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
return [
|
return [
|
||||||
'actions_panel' => 'Actions',
|
'actions_panel' => 'Actions',
|
||||||
'album_no_photos_p1' => 'This album does not yet have any photos.',
|
'album_no_photos_p1' => 'No photos in this album',
|
||||||
'album_no_photos_p2' => 'Click the "Upload photos" button below to get started.',
|
'album_no_photos_p2' => 'Click the "Upload photos" button below to get started.',
|
||||||
'album_no_photos_button' => 'Upload photos',
|
'album_no_photos_button' => 'Upload photos',
|
||||||
'album_photos_tab' => 'Photos',
|
'album_photos_tab' => 'Photos',
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
@if (count($albums) == 0)
|
@if (count($albums) == 0)
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h3>@lang('admin.no_albums_title')</h3>
|
<h4 class="text-danger"><b>@lang('admin.no_albums_title')</b></h4>
|
||||||
<p>@lang('admin.no_albums_text')</p>
|
<p>@lang('admin.no_albums_text')</p>
|
||||||
<p style="margin-top: 40px;">
|
<p style="margin-top: 40px;">
|
||||||
<a href="{{ route('albums.create') }}" class="btn btn-lg btn-success">@lang('admin.create_album')</a>
|
<a href="{{ route('albums.create') }}" class="btn btn-lg btn-success">@lang('admin.create_album')</a>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<div role="tabpanel" class="tab-pane active" id="photos-tab">
|
<div role="tabpanel" class="tab-pane active" id="photos-tab">
|
||||||
@if ($album->photos()->count() == 0)
|
@if ($album->photos()->count() == 0)
|
||||||
<div class="text-center" style="margin-top: 30px;">
|
<div class="text-center" style="margin-top: 30px;">
|
||||||
<p><b class="text-danger">@lang('admin.album_no_photos_p1')</b></p>
|
<h4 class="text-danger"><b>@lang('admin.album_no_photos_p1')</b></h4>
|
||||||
<p>@lang('admin.album_no_photos_p2')</p>
|
<p>@lang('admin.album_no_photos_p2')</p>
|
||||||
<p style="margin-top: 30px;"><button id="upload-button" class="btn btn-lg btn-success">@lang('admin.album_no_photos_button')</button></p>
|
<p style="margin-top: 30px;"><button id="upload-button" class="btn btn-lg btn-success">@lang('admin.album_no_photos_button')</button></p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="metadata_name">File name:</td>
|
<td class="metadata_name">File name:</td>
|
||||||
<td class="metadata_value">{{ $photo->name }}</td>
|
<td class="metadata_value">{{ $photo->file_name }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@if (strlen($photo->taken_at) > 0)
|
@if (strlen($photo->taken_at) > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user