Skip to content

Commit

Permalink
Updated: intervention image
Browse files Browse the repository at this point in the history
  • Loading branch information
we-vikram-wri231 committed Mar 15, 2024
1 parent c8ec159 commit 01cd184
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions Http/Controllers/Backend/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use Intervention\Image\Drivers\Gd\Driver;
use Intervention\Image\ImageManager;
use Symfony\Component\HttpFoundation\BinaryFileResponse;

use WebReinvent\VaahCms\Models\Media;
Expand Down Expand Up @@ -345,6 +347,7 @@ public function upload(Request $request): JsonResponse
return response()->json($response);
}


try {
//add year and month folder
if ($request->folder_path == 'public/media') {
Expand Down Expand Up @@ -402,9 +405,13 @@ public function upload(Request $request): JsonResponse

//create thumbnail if image
if ($data['type'] == 'image') {
$image = \Image::make($data['full_path'])->fit(180, 101, function ($constraint) {
$constraint->aspectRatio();
});

$manager = new ImageManager(
new Driver()
);

$image = $manager->read($data['full_path'])->scale(180, 101);

$name_details = pathinfo($data['full_path']);
$thumbnail_name = $name_details['filename'].'-thumbnail.'.$name_details['extension'];
$thumbnail_path = $request->folder_path.'/'.$thumbnail_name;
Expand Down
4 changes: 2 additions & 2 deletions Vue/vaahtwo/pages/profile/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ onMounted(async () => {
<div class="field mb-4 flex justify-content-between align-items-center">
<Avatar :image="store.profile.avatar"
v-if="store.profile"
class="mr-3"
class="mr-3 border-circle"
shape="circle"
size="xlarge">
</Avatar>

<div class="w-max">
<FileUploader v-if="root.assets.urls"
placeholder="Upload Avatar"
:maxFileSize="200000"
:maxFileSize="10000000"
:is_basic="true"
:auto_upload="true"
:uploadUrl="root.assets.urls.upload" >
Expand Down

0 comments on commit 01cd184

Please sign in to comment.