Before you start you should install LiipImagineBundle and KnpGaufretteBundle
First, grab the ThraceMediaBundle using composer (symfony 2.1 pattern)
Add on composer.json (see http://getcomposer.org/)
"require" : {
// ...
"thrace-project/media-bundle":"dev-master",
}
To start using the bundle, register it in your Kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Thrace\MediaBundle\ThraceMediaBundle(),
);
// ...
}
- jquery (http://jquery.com/)
- jqueryUI (http://jqueryui.com/)
- plupload (https://github.com/moxiecode/plupload)
- Jcrop (https://github.com/tapmodo/Jcrop)
- colorbox (https://github.com/jackmoore/colorbox)
- jwplayer (http://www.longtailvideo.com/jw-player/)
Put the sources somewhere in the web folder. EX: web/plugins/
knp_gaufrette:
adapters:
media:
local:
directory: %kernel.root_dir%/../web/media
temp:
local:
directory: %kernel.root_dir%/../web/media/temp
filesystems:
media:
adapter: media
alias: media_filesystem
temp:
adapter: temp
alias: temp_filesystem
Note - Media adapter is used to store already persisted files and temp adapter is used to store files which are still not persisted to DB or being manipulated by user.
thrace_media:
temporary_filesystem_key: temp #gaufrette temporary filesystem key
media_filesystem_key: media # #gaufrette media filesystem key
jwplayer:
key: "Kh16KTAXkhlYsWK6JnxLL/qK9hjIUn/f9TU1LA==" #get the key from jwplayer website
html5player: "plugins/jwplayer/jwplayer.html5.js" #set the path to html5 js file
flashplayer: "plugins/jwplayer/jwplayer.flash.swf" #set the path to flash file
# app/config/routing.yaml
thrace_media_backend:
resource: "@ThraceMediaBundle/Resources/config/routing/backend.xml"
prefix: /admin
thrace_media_frontend:
resource: "@ThraceMediaBundle/Resources/config/routing/frontend.xml"
prefix: /
ThraceMediaBundle uses ajax/post requests to upload, render, crop, rotate and reset images and files.
- thrace_media_image_upload (used to upload image: /_thrace-media/image-upload/
- thrace_media_image_crop (used to crop image): /_thrace-media/image-crop
- thrace_form_media_image_rotate (used to rotate image): /_thrace-media/image-rotate
- thrace_form_media_image_reset (used to reset image): /_thrace-media/image-reset
- thrace_media_image_render_temporary (used to render temporary image): /_thrace-media/image-render-temporary
- thrace_media_render_temporary (used to render temporary media video/audio): /_thrace-media/render-temporary
- thrace_media_file_upload (used to upload file): /_thrace_media/file_upload
# app/config/security.yml
security:
# ...
access_control:
- { path: ^/_thrace_media/image-upload, roles: ROLE_ADMIN }
- { path: ^/_thrace_media/image-crop, roles: ROLE_ADMIN }
- { path: ^/_thrace_media/image-rotate, roles: ROLE_ADMIN }
- { path: ^/_thrace_media/image-reset, roles: ROLE_ADMIN }
- { path: ^/_thrace-media/image-render-temporary, roles: ROLE_ADMIN }
- { path: ^/_thrace-media/render-temporary, roles: ROLE_ADMIN }
- { path: ^/_thrace_media/file-upload, roles: ROLE_ADMIN }
Or you can secure ^/admin section and then prefix the bundle routing.
# app/config/routing.yml
thrace_media_backend:
resource: "@ThraceMediaBundle/Resources/config/routing/backend.xml"
prefix: /admin
For more information go to symfony documentation
$ php app/console thrace:media:cache-clear --maxAge=7200