Hook: media.uploaded
Overview
Type: Action
Location: app/Services/MediaService.php, MediaController.php
Fired after a file is uploaded and saved to database. Use this for post-processing tasks like image optimization, thumbnail generation, or syncing to external storage.
Parameters
| Param | Type | Description |
|---|---|---|
$media |
Media | Newly created media record |
$file |
UploadedFile | Original uploaded file |
$data |
array | Validated upload metadata |
Usage Example
Hook::addAction('media.uploaded', function ($media, $file) {
if (str_starts_with($media->mime_type, 'image/')) {
dispatch(new GenerateWebpVariant($media));
}
});
Related Hooks
media.url - Rewrite media URLs
media.delete.should - Prevent deletion
PolyCMS is an open-source content management system for modern web applications, inspired by the WordPress plugin and theme ecosystem but built on top of the Laravel framework. It is designed to provide a complete foundation for content publishing, e-commerce, multi-language support, and extensible module architecture — powered by a Vue 3 admin panel with data served entirely through RESTful APIs.
Whether you're building a blog, a documentation site, an online store, or a multi-tenant SaaS platform, PolyCMS aims to give you a comprehensive starting scaffold so you can ship quickly and extend easily through integrated modules and themes. In particular, themes in PolyCMS follow a multi-theme architecture — one Main theme and an unlimited number of Sub themes can run side by side on the same installation.
We hope this ready-made foundation proves useful for building your next website, blog, or web app, saving you from having to start completely from scratch.