event photo wasserzeichen umgesetzt. Event admins können eigene einsetzen (als branding) falls das Paket es erlaubt. der Super Admin kann für die günstigen Pakete eigene Wasserzeichen erzwingen
This commit is contained in:
@@ -14,6 +14,7 @@ use App\Services\Packages\PackageUsageTracker;
|
||||
use App\Services\Storage\EventStorageManager;
|
||||
use App\Support\ApiError;
|
||||
use App\Support\ImageHelper;
|
||||
use App\Support\WatermarkConfigResolver;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
@@ -153,13 +154,38 @@ class PhotoController extends Controller
|
||||
$thumbnailPath = $thumbnailRelative;
|
||||
}
|
||||
|
||||
// Apply watermark policy (in-place) to original and thumbnail where applicable.
|
||||
$watermarkConfig = WatermarkConfigResolver::resolve($event);
|
||||
if ($watermarkConfig['type'] !== 'none' && ! empty($watermarkConfig['asset'])) {
|
||||
ImageHelper::applyWatermarkOnDisk($disk, $path, $watermarkConfig);
|
||||
if ($thumbnailRelative) {
|
||||
ImageHelper::applyWatermarkOnDisk($disk, $thumbnailPath, $watermarkConfig);
|
||||
}
|
||||
}
|
||||
|
||||
$watermarkConfig = WatermarkConfigResolver::resolve($event);
|
||||
$watermarkedPath = $path;
|
||||
$watermarkedThumb = $thumbnailPath;
|
||||
|
||||
if ($watermarkConfig['type'] !== 'none' && ! empty($watermarkConfig['asset']) && ! ($watermarkConfig['serve_originals'] ?? false)) {
|
||||
$watermarkedPath = ImageHelper::copyWithWatermark($disk, $path, "events/{$eventSlug}/watermarked/{$filename}", $watermarkConfig) ?? $path;
|
||||
if ($thumbnailRelative) {
|
||||
$watermarkedThumb = ImageHelper::copyWithWatermark(
|
||||
$disk,
|
||||
$thumbnailPath,
|
||||
"events/{$eventSlug}/watermarked/thumbnails/{$filename}",
|
||||
$watermarkConfig
|
||||
) ?? $thumbnailPath;
|
||||
}
|
||||
}
|
||||
|
||||
$photoAttributes = [
|
||||
'event_id' => $event->id,
|
||||
'original_name' => $file->getClientOriginalName(),
|
||||
'mime_type' => $file->getMimeType(),
|
||||
'size' => $file->getSize(),
|
||||
'file_path' => $path,
|
||||
'thumbnail_path' => $thumbnailPath,
|
||||
'file_path' => $watermarkedPath,
|
||||
'thumbnail_path' => $watermarkedThumb,
|
||||
'width' => null, // Filled below
|
||||
'height' => null,
|
||||
'status' => 'pending', // Requires moderation
|
||||
@@ -179,17 +205,36 @@ class PhotoController extends Controller
|
||||
$photo = Photo::create($photoAttributes);
|
||||
|
||||
// Record primary asset metadata
|
||||
$checksum = hash_file('sha256', $file->getRealPath());
|
||||
$storedPath = Storage::disk($disk)->path($path);
|
||||
$checksum = file_exists($storedPath) ? hash_file('sha256', $storedPath) : hash_file('sha256', $file->getRealPath());
|
||||
$storedSize = Storage::disk($disk)->exists($path) ? Storage::disk($disk)->size($path) : $file->getSize();
|
||||
$asset = $this->eventStorageManager->recordAsset($event, $disk, $path, [
|
||||
'variant' => 'original',
|
||||
'mime_type' => $file->getMimeType(),
|
||||
'size_bytes' => $file->getSize(),
|
||||
'size_bytes' => $storedSize,
|
||||
'checksum' => $checksum,
|
||||
'status' => 'hot',
|
||||
'processed_at' => now(),
|
||||
'photo_id' => $photo->id,
|
||||
]);
|
||||
|
||||
$watermarkedAsset = null;
|
||||
if ($watermarkedPath !== $path) {
|
||||
$watermarkedAsset = $this->eventStorageManager->recordAsset($event, $disk, $watermarkedPath, [
|
||||
'variant' => 'watermarked',
|
||||
'mime_type' => $file->getMimeType(),
|
||||
'size_bytes' => Storage::disk($disk)->exists($watermarkedPath)
|
||||
? Storage::disk($disk)->size($watermarkedPath)
|
||||
: null,
|
||||
'status' => 'hot',
|
||||
'processed_at' => now(),
|
||||
'photo_id' => $photo->id,
|
||||
'meta' => [
|
||||
'source_variant_id' => $asset->id,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
if ($thumbnailRelative) {
|
||||
$this->eventStorageManager->recordAsset($event, $disk, $thumbnailRelative, [
|
||||
'variant' => 'thumbnail',
|
||||
@@ -205,6 +250,21 @@ class PhotoController extends Controller
|
||||
],
|
||||
]);
|
||||
}
|
||||
if ($watermarkedThumb !== $thumbnailPath) {
|
||||
$this->eventStorageManager->recordAsset($event, $disk, $watermarkedThumb, [
|
||||
'variant' => 'watermarked_thumbnail',
|
||||
'mime_type' => 'image/jpeg',
|
||||
'status' => 'hot',
|
||||
'processed_at' => now(),
|
||||
'photo_id' => $photo->id,
|
||||
'size_bytes' => Storage::disk($disk)->exists($watermarkedThumb)
|
||||
? Storage::disk($disk)->size($watermarkedThumb)
|
||||
: null,
|
||||
'meta' => [
|
||||
'source_variant_id' => $watermarkedAsset?->id ?? $asset->id,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
$photo->update(['media_asset_id' => $asset->id]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user