Update: ersetzten Plugin-Ordner ignorieren; Uploads trotz open_basedir
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m17s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m35s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m43s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 5m14s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 5m18s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 5m16s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 5m11s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m40s
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m17s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m35s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m43s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 5m14s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 5m18s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 5m16s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 5m11s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m40s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
30d2e42ee3
commit
6bede3e2ee
103 changed files with 477 additions and 397 deletions
|
|
@ -54,6 +54,35 @@ class Images
|
|||
*
|
||||
* @return string Pfad im Speicher „uploads“
|
||||
*/
|
||||
/**
|
||||
* Führt $callback mit dem Pfad einer lokalen Kopie des Uploads aus.
|
||||
*
|
||||
* Die Datei wird erst per move_uploaded_file ins eigene storage verschoben:
|
||||
* Auf Shared Hosting sperrt open_basedir oft das direkte Lesen im
|
||||
* PHP-Upload-Verzeichnis (getRealPath() liefert dann false).
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @param callable(string): T $callback
|
||||
* @return T
|
||||
*/
|
||||
public static function withLocalCopy(UploadedFile $file, callable $callback): mixed
|
||||
{
|
||||
$directory = storage_path('app/tmp');
|
||||
|
||||
if (! is_dir($directory)) {
|
||||
@mkdir($directory, 0775, true);
|
||||
}
|
||||
|
||||
$path = $file->move($directory, 'upload-'.Str::random(16))->getPathname();
|
||||
|
||||
try {
|
||||
return $callback($path);
|
||||
} finally {
|
||||
@unlink($path);
|
||||
}
|
||||
}
|
||||
|
||||
public function storeContentImage(UploadedFile $file, string $directory): string
|
||||
{
|
||||
$disk = Storage::disk('uploads');
|
||||
|
|
@ -65,10 +94,12 @@ class Images
|
|||
return $name.'.gif';
|
||||
}
|
||||
|
||||
self::raiseMemoryLimitFor($file->getRealPath());
|
||||
$image = ImageManager::usingDriver(Driver::class)->decodePath($file->getRealPath());
|
||||
$image->scaleDown(width: 2000);
|
||||
$disk->put($name.'.webp', $image->encode(new WebpEncoder(quality: 84))->toString());
|
||||
self::withLocalCopy($file, function (string $path) use ($disk, $name) {
|
||||
self::raiseMemoryLimitFor($path);
|
||||
$image = ImageManager::usingDriver(Driver::class)->decodePath($path);
|
||||
$image->scaleDown(width: 2000);
|
||||
$disk->put($name.'.webp', $image->encode(new WebpEncoder(quality: 84))->toString());
|
||||
});
|
||||
|
||||
return $name.'.webp';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue