8000 refactor thumbnails related functions · trdynet/laravel-filemanager@b0bc46a · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit b0bc46a

Browse files
committed
refactor thumbnails related functions
1 parent 1d07319 commit b0bc46a

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

src/LfmFileRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public function move($new_lfm_path)
4444
return File::move($this->path, $new_lfm_path->path('storage'));
4545
}
4646

47-
public function save($file, $new_filename)
47+
public function save($file)
4848
{
49-
$dest_file_path = $this->path . '/' . $new_filename;
49+
$dest_file_path = $this->path;
5050

5151
File::move($file->getRealPath(), $dest_file_path);
5252

src/LfmPath.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ private function saveFile($file, $new_filename)
276276
{
277277
$should_create_thumbnail = $this->shouldCreateThumb($file);
278278

279-
$this->setName(null)->thumb(false)->storage->save($file, $new_filename);
279+
$this->setName( 8000 $new_filename)->thumb(false)->storage->save(file_get_contents($file));
280280

281281
if ($should_create_thumbnail) {
282282
$this->makeThumbnail($new_filename);
@@ -290,21 +290,14 @@ public function makeThumbnail($filename)
290290
// create folder for thumbnails
291291
$this->setName(null)->thumb(true)->createFolder();
292292

293-
$image_path = $this->thumb(false)->setName($filename)->path('storage');
294-
295-
$image_content = $this->storage->get($image_path);
296-
297-
$thumb_path = $this->thumb(true)->setName($filename)->path('absolute');
293+
$image_content = $this->thumb(false)->setName($filename)->get();
298294

299295
// generate cropped thumbnail
300296
$image = Image::make($image_content)
301297
->fit(config('lfm.thumb_img_width', 200), config('lfm.thumb_img_height', 200))
302-
->save($thumb_path);
303-
304-
\Log::info($this->storage->rootPath());
305-
\Log::info($thumb_path);
298+
->encode();
306299

307-
$this->setName(null)->thumb(true)->storage->save(new UploadedFile($thumb_path, $filename), $filename);
300+
$this->setName($filename)->thumb(true)->storage->save($image);
308301
}
309302

310303
private function shouldCreateThumb($file)

src/LfmStorageRepository.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ public function move($new_lfm_path)
4242
return $this->disk->move($this->path, $new_lfm_path->path('storage'));
4343
}
4444

45-
public function save($file, $new_filename)
45+
public function save($file_content)
4646
{
47-
$this->disk->putFileAs($this->path, $file, $new_filename);
47+
$this->disk->put($this->path, $file_content);
4848
}
4949

5050
public function url($path)
5151
{
5252
return $this->disk->url($path);
5353
}
5454

55-
public function makeDirectory($mode, $recursive, $force)
55+
public function makeDirectory()
5656
{
57-
$this->disk->makeDirectory($this->path, $mode, $recursive, $force);
57+
$this->disk->makeDirectory($this->path, ...$arguments);
5858

5959
$this->disk->setVisibility($this->path, 'public');
6060
}

src/RepositoryContract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ public function rootPath();
88

99
public function move($new_lfm_path);
1010

11-
public function save($file, $new_filename);
11+
public function save($file);
1212
}

0 commit comments

Comments
 (0)
0