aciliainternet / asset-bundle
Acilia 资产包
1.0.0
2021-12-29 13:41 UTC
Requires
- php: >=7.2
- intervention/image: ^2.7
- symfony/framework-bundle: ^4.4
README
Acilia Asset Bundle for Symfony2 和 symfony3
AssetBundle
由 Acilia Internet 开发的 Symfony2 和 Symfony3 资产包
此包允许上传和裁剪图像,并将图像作为“资产”实体保存到数据库中。
安装和配置
使用 Composer 非常简单,运行
composer require aciliainternet/asset-bundle
将 AssetBundle 添加到您的应用程序内核中
// app/AppKernel.php public function registerBundles() { return array( // ... new Acilia\Bundle\AssetBundle\AciliaAssetBundle(), // ... ); }
将资源添加到您的公共目录中
php bin/console assets:install web/backend/
在模板上链接资源
{% stylesheets 'bundles/aciliaasset/css/plugins/cropper/cropper.min.css' filter='cssrewrite' output='css/compiled/app.css' %} <link rel="stylesheet" href="{{ asset_url }}" /> {% endstylesheets %} % javascripts 'bundles/aciliaasset/js/plugins/cropper/cropper.min.js' 'bundles/aciliaasset/js/cropper.js' 'bundles/aciliaasset/js/uploader.js' output='js/compiled/app.js' %} <script src="{{ asset_url }}"></script> {% endjavascripts %}
配置示例
您必须配置一些参数
acilia_asset: assets_images: Resources/config/images.yml # yaml file to indicate ratios and sizes assets_dir: /var/www/media/ # path to where store the images uploaded assets_public: /media # relative path to the images on the web server (default /media) assets_domain: www.my-images.com # domain from which the images can be access
图像尺寸文件示例
ratios: { 177: 16x9, 100: 1x1, 200: 2x1, 133: 4x3 } renditions: main_highlight: { large: 1200x675, medium: 1024x576, small: 640x640 } big_cards: { large: 1200x675, medium: 1024x576, small: 640x360 } secondary_highlight: { large: 600x338, medium: 1024x576, small: 640x360 } entities: card: image: title: Main renditions: [ main_highlight, secondary_highlight, big_cards ] attribute: image serie: main: title: Main image renditions: [ main_highlight, big_cards ] attribute: picture