Add images to tasks
Everyone who may comment on a task sends images to it, e.g. photos taken with a phone. The server stores an upright, at most 2560 px JPEG without EXIF data (no location) and a 400 px thumbnail on the private disk, served only to those who see the job. Uploaders change captions (also the alt text) and remove their own images; admin and management may remove anyone's (jobs.remove-any-task-image). Removing a task also removes its image files. Livewire's temporary upload limit is raised to PHP's 40 MB so that the page's own 12 MB limit gives a translated message. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Jobs\Domain\ValueObjects;
|
||||
|
||||
use App\Modules\Jobs\Domain\Exceptions\InvalidTaskImageCaption;
|
||||
|
||||
/**
|
||||
* The optional caption of a task image, also its alternative text.
|
||||
*/
|
||||
final readonly class TaskImageCaption
|
||||
{
|
||||
public const int MAX_LENGTH = 255;
|
||||
|
||||
private function __construct(public string $value) {}
|
||||
|
||||
/**
|
||||
* Null for an empty caption.
|
||||
*
|
||||
* @throws InvalidTaskImageCaption
|
||||
*/
|
||||
public static function fromNullable(?string $value): ?self
|
||||
{
|
||||
$value = trim(preg_replace('/\s+/u', ' ', (string) $value) ?? (string) $value);
|
||||
|
||||
if ($value === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (mb_strlen($value) > self::MAX_LENGTH) {
|
||||
throw new InvalidTaskImageCaption;
|
||||
}
|
||||
|
||||
return new self($value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user