Search by

austral / entity-file-bundle

Matthieu Beurelaustral

File uploads, thumbnails and download for entity to Symfony. Compress file with squoosh-cli

Package info

github.com/austral-project/entity-file-bundle

Homepage

Type:symfony-bundle

pkg:composer/austral/entity-file-bundle

Statistics

Installs: 3 285

Dependents: 8

Suggesters: 0

Stars: 1

Open Issues: 0

v3.1.2 2024-07-15 14:19 UTC

This package is auto-updated.

Last update: 2026-11-26 13:59:59 UTC


README

Version CI PHP Symfony License

File uploads, thumbnails and download for entity to Symfony. Compress file with squoosh-cli

This bundle is part of Austral, a modular back office and CMS for Symfony.

Requirements

  • PHP 8.4 or higher
  • Symfony 7.4

Installation

composer require austral/entity-file-bundle

If you do not use Symfony Flex, register the bundle in config/bundles.php:

return [
    // ...
    Austral\EntityFileBundle\AustralEntityFileBundle::class => ['all' => true],
];

Configuration

# config/packages/austral_entity_file.yaml
austral_entity_file:
    compression:
        command: ''                 # command that compresses the uploaded images; none when not set
        options:
            webp:       { quality: 70 }
    cropper:                        # merged with the default croppers: desktop, tablet, mobile
        desktop:    { name: desktop, picto: austral-picto-monitor, ratio: '16/9' }
    image_size:                     # merged with the default sizes (default: 100 to 10000 pixels)
        default:
            width:  { min: 100, max: 10000 }
            height: { min: 100, max: 10000 }
    uploads:                        # merged with the default rules: default_image, default_file (2M)
        default_image:
            size:       { max: '5M' }
            mimeTypes:  [ 'image/jpeg', 'image/png', 'image/webp' ]

The configuration of the application is merged with the default values, then with the values declared by the bundles (the avatar of security-bundle, for example): a list (mimeTypes, croppers) replaces the list it overrides, and a value that is not set keeps the default one.

# config/routes/austral_entity_file.yaml: thumbnails and downloads
austral_entity_file:
    resource: '@AustralEntityFileBundle/Resources/config/routes.yaml'

With the Austral recipes, Flex creates both files.

Usage

Administration

When austral/admin-bundle 4 is installed, the configuration page of the admin (/austral-admin/status-configuration) shows the category "Uploads": the rules default_image and default_file, then each file field of the entities, with its maximum size, accepted MIME types, size of the images and upload folder. A rule without maximum size or that accepts every MIME type is a warning: set size.max and mimeTypes in austral_entity_file.uploads.

Documentation

The full documentation is available at https://austral.dev.

Versions

Bundle Symfony PHP Branch
4.x 7.4 ≥ 8.4 4.x
3.1 5.4 / 6.4 ≥ 8.0 3.1 (maintenance)

See the CHANGELOG and, to upgrade from 3.1, UPGRADE-4.0.

Contributing

Contributions are welcome: see the contributing guide. To report a security issue, follow the security policy.

License

MIT, see LICENSE.

Credits

Created by Matthieu Beurel. Sponsored by Yipikai Studio.