Installation
Add to composer.json:
"require": {
"c2is/bigfoot-media-bundle": "dev-master"
}
Run composer update and enable in AppKernel.php:
new C2is\BigfootMediaBundle\BigfootMediaBundle(),
Configuration
Update config.yml with your storage paths:
bigfoot_media:
upload_dir: "%kernel.root_dir%/../web/uploads"
thumbnail_dir: "%kernel.root_dir%/../web/uploads/thumbs"
First Use Case Create a form type with media upload handling:
use C2is\BigfootMediaBundle\Form\Type\MediaType;
$builder->add('media', MediaType::class);
File Upload Handling
Use MediaType in forms to auto-generate upload fields:
$form = $this->createFormBuilder($entity)
->add('image', MediaType::class, [
'label' => 'Profile Image',
'allowed_mime_types' => ['image/jpeg', 'image/png']
])
->getForm();
Thumbnail Generation Configure via YAML:
bigfoot_media:
thumbnail_sizes: [100x100, 200x200]
Call generateThumbnails() on the media entity post-upload.
Entity Integration
Extend C2is\BigfootMediaBundle\Entity\Media or use traits:
use C2is\BigfootMediaBundle\Traits\MediaTrait;
class Product {
use MediaTrait;
// ...
}
Symfony Event Listeners
Hook into bigfoot.media.pre_upload and bigfoot.media.post_upload events for custom logic.
Deprecated Bundle
vich/uploader-bundle if possible.Hardcoded Paths
upload_dir/thumbs/{hash}.{ext}.C2is\BigfootMediaBundle\Service\ThumbnailService for custom logic.No Laravel Support
// Example facade (unofficial)
class BigfootMediaFacade {
public static function upload($file) { /* ... */ }
}
Check Uploads Directory
Ensure upload_dir is writable (chmod 775).
Event Debugging Dump events in a listener:
$event->getMedia()->getPath(); // Debug file path
MIME Type Validation
Override C2is\BigfootMediaBundle\Validator\Constraints\MimeType if validation fails.
Custom Storage
Extend C2is\BigfootMediaBundle\Storage\FilesystemStorage for S3/Azure.
Validation Rules
Add constraints to MediaType:
->add('media', MediaType::class, [
'constraints' => [
new \C2is\BigfootMediaBundle\Validator\Constraints\MaxSize(['maxSize' => '10M'])
]
])
Template Overrides
Override BigfootMediaBundle::media.html.twig for custom display logic.
How can I help you explore Laravel packages today?