, (*1)
Yii2 Media to manage files on Yii2 site like Wordpress Media Management, (*2)
Installation
The preferred way to install this extension is through composer., (*3)
Either run, (*4)
$ php composer.phar require cinghie/yii2-media "*"
or add, (*5)
"cinghie/yii2-media": "*"
Configuration
Make sure that you have properly configured db
application component
and run the following command:, (*6)
$ php yii migrate/up --migrationPath=@vendor/cinghie/yii2-media/migrations
2. Set configuration file
Set on your configuration file:, (*7)
'modules' => [
// Yii2 Media
'media' => [
'class' => 'cinghie\media\Media',
'mediaNameType' = 'casual'; // casual or original
'mediaPath' => '@frontend/web/media/',
'mediaThumbsPath' => '@frontend/web/media/thumbs/',
'mediaURL' => $params['media']['mediaURL'],
'mediaThumbsURL' => $params['media']['mediaThumbsURL'],
'mediaRoles' => ['admin'],
'mediaType' = ['jpg','jpeg','gif','png','csv','xls','xlx','pdf','txt','doc','docs','mp3','mp4'];
'tinyPngAPIKey' => 'YOUR_TINIFY_API_KEY',
'showTinify' => false,
'showTitles' => false
],
]
2. Set frontend filter
To disable media management on frontend, set on config:, (*8)
'modules' => [
// Yii2 Media
'media' => [
'class' => 'cinghie\media\Media',
'as frontend' => 'cinghie\media\filters\FrontendFilter',
],
]
3. Install FFmpeg
On Linux, (*9)
apt-get install ffmpeg
whereis ffmpeg
Overrides
Override controller example, on modules config, (*10)
'modules' => [
'media' => [
'class' => 'cinghie\media\Media',
'controllerMap' => [
'default' => 'app\controllers\DefaultController',
]
]
],
Override models example, on modules config, (*11)
'modules' => [
'media' => [
'class' => 'cinghie\media\media',
'modelMap' => [
'Media' => 'app\models\media\Media',
'MediaSettings' => 'app\models\media\MediaSettings',
]
]
],
Override view example, on components config, (*12)
'components' => [
'view' => [
'theme' => [
'pathMap' => [
'@cinghie/media/views/default' => '@app/views/media/default',
],
],
],
],