From 09b4bc60ddf397e91a6e8f9d5516c1f6d27cbe7e Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Sun, 19 Apr 2020 15:46:35 +0100 Subject: [PATCH] Images are now refreshed correctly after resizing/rotating when using a private S3 album. Corrected some more icons to Font Awesome v5. #147 #141 --- app/AlbumSources/AmazonS3Source.php | 2 +- app/Http/Controllers/Admin/PhotoController.php | 9 ++++++--- resources/js/albums.js | 13 +++++++------ resources/views/install/navbar.blade.php | 2 +- resources/views/themes/base/gallery/index.blade.php | 2 +- .../views/themes/base/gallery/statistics.blade.php | 2 +- .../themes/base/gallery/user_profile.blade.php | 6 +++--- .../base/partials/gallery_child_album.blade.php | 4 ++-- 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/AlbumSources/AmazonS3Source.php b/app/AlbumSources/AmazonS3Source.php index 948c534..2004159 100644 --- a/app/AlbumSources/AmazonS3Source.php +++ b/app/AlbumSources/AmazonS3Source.php @@ -140,7 +140,7 @@ class AmazonS3Source extends AlbumSourceBase implements IAlbumSource, IAnalysisQ 'Key' => $this->getPathToPhoto($photo, $thumbnail) ]); - return $client->createPresignedRequest($cmd, '+5 minutes')->getUri(); + return (string)$client->createPresignedRequest($cmd, '+5 minutes')->getUri(); } return $client->getObjectUrl($this->configuration->container_name, $this->getPathToPhoto($photo, $thumbnail)); diff --git a/app/Http/Controllers/Admin/PhotoController.php b/app/Http/Controllers/Admin/PhotoController.php index c564201..921b354 100644 --- a/app/Http/Controllers/Admin/PhotoController.php +++ b/app/Http/Controllers/Admin/PhotoController.php @@ -162,7 +162,7 @@ class PhotoController extends Controller $request->session()->flash('success', trans('admin.delete_photo_successful_message', ['name' => $photo->name])); } - public function flip($photoId, $horizontal, $vertical) + public function flip(Request $request, $photoId, $horizontal, $vertical) { $this->authorizeAccessToAdminPanel(); @@ -176,6 +176,8 @@ class PhotoController extends Controller // Log an activity record for the user's feed $this->createActivityRecord($photo, 'photo.edited'); + + return $photo->thumbnailUrl($request->get('t', 'admin-preview')); } public function move(Request $request, $photoId) @@ -241,13 +243,13 @@ class PhotoController extends Controller return response()->json($result); } - public function regenerateThumbnails($photoId) + public function regenerateThumbnails(Request $request, $photoId) { $this->authorizeAccessToAdminPanel(); $photo = $this->loadPhoto($photoId, 'change-metadata'); - $result = ['is_successful' => false, 'message' => '']; + $result = ['is_successful' => false, 'message' => '', 'thumbnail_url' => '']; try { @@ -255,6 +257,7 @@ class PhotoController extends Controller $photoService->regenerateThumbnails(); $result['is_successful'] = true; + $result['thumbnail_url'] = $photo->thumbnailUrl($request->get('t', 'admin-preview')); } catch (\Exception $ex) { diff --git a/resources/js/albums.js b/resources/js/albums.js index eaecc59..c41b22a 100644 --- a/resources/js/albums.js +++ b/resources/js/albums.js @@ -280,10 +280,11 @@ function EditPhotosViewModel(album_id, language, urls) { } $('.loading', parent).show(); - $.post(url, function () { + $.post(url, function (response) { var image = $('img.photo-thumbnail', parent); - var originalUrl = image.data('original-src'); - image.attr('src', originalUrl + "&_=" + new Date().getTime()); + + // response from server is the URL to the modified image + image.attr('src', response); $('.loading', parent).hide(); }); @@ -363,10 +364,10 @@ function EditPhotosViewModel(album_id, language, urls) { url = url.replace(/\/0$/, '/' + this.photoIDs[0]); $('.loading', parent).show(); - $.post(url, function () { + $.post(url, function (response) { var image = $('img.photo-thumbnail', parent); - var originalUrl = image.data('original-src'); - image.attr('src', originalUrl + "&_=" + new Date().getTime()); + + image.attr('src', response.thumbnail_url); $('.loading', parent).hide(); }); diff --git a/resources/views/install/navbar.blade.php b/resources/views/install/navbar.blade.php index 701fa53..cb21d84 100644 --- a/resources/views/install/navbar.blade.php +++ b/resources/views/install/navbar.blade.php @@ -1,5 +1,5 @@