Skip to content

Instantly share code, notes, and snippets.

@igormukhingmailcom
Created May 16, 2015 20:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save igormukhingmailcom/b925ff7c852d104b4643 to your computer and use it in GitHub Desktop.
Save igormukhingmailcom/b925ff7c852d104b4643 to your computer and use it in GitHub Desktop.
Symfony2 configuration for file uploads & cropping at EasyAdminBundle with JbFileUploaderBundle for multiple entities
$(document).ready(function()
{
$('.jb_fileupload').jbFileUpload();
});
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/", "SymfonyStandard": "app/" }
},
"repositories": [{
"type": "vcs",
"url": "https://github.com/igormukhingmailcom/EasyAdminBundle.git"
}],
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.6.*",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0,>=3.0.12",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"knplabs/knp-gaufrette-bundle": "*@dev",
"liip/imagine-bundle": "~1.1.0",
"oneup/uploader-bundle": "~1.3",
"jbouzekri/file-uploader-bundle": "~2.0",
"javiereguiluz/easyadmin-bundle": "dev-patch-1"
},
"require-dev": {
"sensio/generator-bundle": "~2.3"
},
"scripts": {
"post-root-package-install": [
"SymfonyStandard\\Composer::hookRootPackageInstall"
],
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.6-dev"
}
}
}
easy_admin:
design:
form_theme:
- "EasyAdminBundle:form:bootstrap_3_horizontal_layout.html.twig"
- "JbFileUploaderBundle:Form:fields.html.twig"
assets:
css:
- bundles/jbfileuploader/lib/jquery-file-upload/css/jquery.fileupload.css
- bundles/jbfileuploader/css/jbfileupload.css
- bundles/jbfileuploader/lib/jcrop/css/jquery.Jcrop.min.css
js:
# - //code.jquery.com/jquery-1.11.0.min.js
- bundles/jbfileuploader/lib/jquery-file-upload/js/vendor/jquery.ui.widget.js
- bundles/jbfileuploader/lib/jquery-file-upload/js/jquery.iframe-transport.js
- bundles/jbfileuploader/lib/jquery-file-upload/js/jquery.fileupload.js
- bundles/jbfileuploader/js/jbfileupload.js
- bundles/jbfileuploader/lib/jcrop/js/jquery.Jcrop.js
- bundles/app/js/app.js
entities:
Category:
class: AppBundle\Entity\Category
image_base_path: /media/cache/resolve/category_admin/
list:
fields:
- { property: 'image', type: 'image' }
- { property: 'name' }
- { property: 'description' }
- { property: 'enabled' }
form:
fields:
- { property: 'image', type: 'jb_crop_image_ajax', options: { endpoint: 'category_endpoint', 'crop_options': { 'aspect-ratio': 2.5, 'set-select': "[0,0,500,200]" }} }
- { property: 'name' }
- { property: 'description' }
- { property: 'enabled' }
Offer:
class: AppBundle\Entity\Offer
image_base_path: /media/cache/resolve/offer_admin/
list:
fields:
- { property: 'image', type: 'image' }
- { property: 'name' }
- { property: 'price' }
- { property: 'enabled' }
form:
fields:
- { property: 'position' }
- { property: 'name' }
- { property: 'price' }
- { property: 'image', type: 'jb_crop_image_ajax', options: { endpoint: 'offer_endpoint', 'crop_options': { 'aspect-ratio': 2.5, 'set-select': "[0,0,500,200]" }} }
- { property: 'enabled' }
jb_file_uploader:
resolvers:
heap:
assets:
directory: uploads
category_croped:
assets:
directory: uploads/category/croped
offer_croped:
assets:
directory: uploads/offer/croped
endpoints:
category_endpoint:
upload_resolver: heap
croped_fs: category_croped # this is filesystem name
croped_resolver: category_croped
upload_validators:
Image:
MinWidth: 500
MinHeight: 200
crop_validators:
Crop:
MinWidth: 500
MinHeight: 200
offer_endpoint:
upload_resolver: heap
croped_fs: offer_croped
croped_resolver: offer_croped
upload_validators:
Image:
MinWidth: 500
MinHeight: 200
crop_validators:
Crop:
MinWidth: 500
MinHeight: 200
knp_gaufrette:
stream_wrapper: ~
adapters:
heap:
local:
directory: %kernel.root_dir%/../web/uploads
create: true
category_croped:
local:
directory: %kernel.root_dir%/../web/uploads/category/croped
create: true
offer_croped:
local:
directory: %kernel.root_dir%/../web/uploads/offer/croped
create: true
filesystems:
heap:
adapter: heap
alias: heap_filesystem
category_croped:
adapter: category_croped
alias: category_croped_filesystem
offer_croped:
adapter: offer_croped
alias: offer_croped_filesystem
liip_imagine:
loaders:
stream.heap_wrapper:
stream:
wrapper: gaufrette://heap/
stream.category_croped_wrapper:
stream:
wrapper: gaufrette://category_croped/
stream.offer_croped_wrapper:
stream:
wrapper: gaufrette://offer_croped/
filter_sets:
original: # this is mandatory - `original` is hardcoded in vendor library
data_loader: stream.heap_wrapper
category:
data_loader: stream.category_croped_wrapper
quality: 75
filters:
thumbnail:
size: [500, 200]
mode: outbound
category_admin:
data_loader: stream.category_croped_wrapper
quality: 50
filters:
thumbnail:
size: [100, 40]
mode: outbound
offer:
data_loader: stream.offer_croped_wrapper
quality: 75
filters:
thumbnail:
size: [500, 200]
mode: outbound
offer_admin:
data_loader: stream.offer_croped_wrapper
quality: 50
filters:
thumbnail:
size: [100, 40]
mode: outbound
oneup_uploader:
mappings:
category_endpoint:
frontend: blueimp
storage:
type: gaufrette
filesystem: gaufrette.heap_filesystem
stream_wrapper: gaufrette://heap/
# max_size: 10M
allowed_mimetypes:
- "image/jpg"
- "image/jpeg"
- "image/png"
- "image/gif"
offer_endpoint:
frontend: blueimp
storage:
type: gaufrette
filesystem: gaufrette.heap_filesystem
stream_wrapper: gaufrette://heap/
# max_size: 10M
allowed_mimetypes:
- "image/jpg"
- "image/jpeg"
- "image/png"
- "image/gif"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment