Allow files to be added to notes
This is specifically when a Micropub client is using the JSON syntax and initially uploads the photo via the media endpoint
This commit is contained in:
parent
d3d6913474
commit
76db869af5
11 changed files with 33 additions and 23 deletions
|
|
@ -33,20 +33,20 @@ class ProcessMedia implements ShouldQueue
|
|||
public function handle(ImageManager $manager): void
|
||||
{
|
||||
// Load file
|
||||
$file = Storage::disk('local')->get('media/' . $this->filename);
|
||||
$file = Storage::disk('local')->get($this->filename);
|
||||
|
||||
// Open file
|
||||
try {
|
||||
$image = $manager->read($file);
|
||||
} catch (DecoderException) {
|
||||
// not an image; delete file and end job
|
||||
Storage::disk('local')->delete('media/' . $this->filename);
|
||||
Storage::disk('local')->delete($this->filename);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Save the file publicly
|
||||
Storage::disk('public')->put('media/' . $this->filename, $file);
|
||||
Storage::disk('public')->put($this->filename, $file);
|
||||
|
||||
// Create smaller versions if necessary
|
||||
if ($image->width() > 1000) {
|
||||
|
|
@ -57,13 +57,13 @@ class ProcessMedia implements ShouldQueue
|
|||
$basename = trim(implode('.', $filenameParts), '.');
|
||||
|
||||
$medium = $image->resize(width: 1000);
|
||||
Storage::disk('public')->put('media/' . $basename . '-medium.' . $extension, (string) $medium->encode());
|
||||
Storage::disk('public')->put($basename . '-medium.' . $extension, (string) $medium->encode());
|
||||
|
||||
$small = $image->resize(width: 500);
|
||||
Storage::disk('public')->put('media/' . $basename . '-small.' . $extension, (string) $small->encode());
|
||||
Storage::disk('public')->put($basename . '-small.' . $extension, (string) $small->encode());
|
||||
}
|
||||
|
||||
// Now we can delete the locally saved image
|
||||
Storage::disk('local')->delete('media/' . $this->filename);
|
||||
Storage::disk('local')->delete($this->filename);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue