backend/controllers/MediaController.php
/**
     * Upload media file and store it to database.
     * Media versions can be set from application params.
     *
     * @return array
     */
Upload media file and store it to database.
Media versions can be set from application params.

@return array
Upload media file and store it to database . Media versions can be set from application params . @return array
public function actionAjaxUpload()
    {
        $versions = [
            'large' => [
                'max_width' => Option::get('large_width'),
                'max_height' => Option::get('large_height'),
            ],
            'medium' => [
                'max_width' => Option::get('medium_width'),
                'max_height' => Option::get('medium_height'),
            ],
            'thumbnail' => [
                'max_width' => Option::get('thumbnail_width'),
                'max_height' => Option::get('thumbnail_height'),
                'crop' => 1,
            ],
        ];
        if($userVersions = ArrayHelper::getValue(Yii::$app->params, 'media.versions', [])){
            $versions = ArrayHelper::merge($versions, $userVersions);
        }
        $uploadHandler = new MediaUploadHandler([
            'versions' => $versions,
            'user_dirs' => Option::get('uploads_username_based'),
            'year_month_dirs' => Option::get('uploads_yearmonth_based'),
        ], MediaUploadHandler::NOT_PRINT_RESPONSE);
        $uploadHandler->post();
    }
public function actionAjaxUpload ( ) { $ versions = [ 'large' => [ 'max_width' => Option :: get ( 'large_width' ) , 'max_height' => Option :: get ( 'large_height' ) , ] , 'medium' => [ 'max_width' => Option :: get ( 'medium_width' ) , 'max_height' => Option :: get ( 'medium_height' ) , ] , 'thumbnail' => [ 'max_width' => Option :: get ( 'thumbnail_width' ) , 'max_height' => Option :: get ( 'thumbnail_height' ) , 'crop' => 1 , ] , ] ; if ( $ userVersions = ArrayHelper :: getValue ( Yii :: $ app -> params , 'media.versions' , [ ] ) ) { $ versions = ArrayHelper :: merge ( $ versions , $ userVersions ) ; } $ uploadHandler = new MediaUploadHandler ( [ 'versions' => $ versions , 'user_dirs' => Option :: get ( 'uploads_username_based' ) , 'year_month_dirs' => Option :: get ( 'uploads_yearmonth_based' ) , ] , MediaUploadHandler :: NOT_PRINT_RESPONSE ) ; $ uploadHandler -> post ( ) ; }
Upload media file and store it to database.
Upload media file and store it to database .