Add optional images to slides
Slides (except YouTube) can carry one image. Uploads are validated, rotated by EXIF orientation, scaled to 1600 px and stored as WebP outside webroot, which also strips camera metadata. Images have an alt text (or are marked decorative) and a layout: top, side or full screen (content slides). Files are removed after the commit when a slide is deleted or its image is replaced, with the poll, and `bin/cake images_cleanup` sweeps leftovers. Duplicated slides get their own file. Docker image gains gd with WebP. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8c7818ee40
commit
a395b50894
30 files changed
+1705
-11
No files matched your search
@@ -4,7 +4,11 @@ declare(strict_types=1);
|
||||
namespace App\Model\Table;
|
||||
|
||||
use App\Model\Entity\Poll;
|
||||
use App\Service\ImageService;
|
||||
use ArrayObject;
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Event\EventInterface;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
use Cake\ORM\RulesChecker;
|
||||
use Cake\ORM\Table;
|
||||
@@ -54,6 +58,20 @@ class PollsTable extends Table
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* After the poll is gone for good, so are the image files of its slides (the slides remove
|
||||
* their own; this also sweeps what a crash left behind).
|
||||
*
|
||||
* @param \Cake\Event\EventInterface<\Cake\ORM\Table> $event Event
|
||||
* @param \Cake\Datasource\EntityInterface $entity Deleted poll
|
||||
* @param \ArrayObject<string, mixed> $options Options
|
||||
* @return void
|
||||
*/
|
||||
public function afterDeleteCommit(EventInterface $event, EntityInterface $entity, ArrayObject $options): void
|
||||
{
|
||||
(new ImageService())->deletePoll((int)$entity->get('id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Cake\Validation\Validator $validator Validator instance.
|
||||
* @return \Cake\Validation\Validator
|
||||
|
||||
Reference in new issue
Block a user