zantknight/yii2-cam-capture

This extension is HTML5 Media Capture, integrating with yii2-gallery4

Installs: 237

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 3

Forks: 3

Open Issues: 1

Type:yii2-extension

v1.0.0 2020-04-09 13:18 UTC

This package is auto-updated.

Last update: 2024-04-11 15:46:36 UTC


README

This extension is HTML5 Media Capture, integrating with yii2-gallery4

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist zantknight/yii2-cam-capture "*"

or add

"zantknight/yii2-cam-capture": "*"

to the require section of your composer.json file.

Usage

Note: Working on with yii2-bootstrap4 only, to shift onto bootstrap4, follow this instruction

  1. If you have not migrate gallery4 yet, simply execute migration by calling this command
    php yii migrate --migrationPath=@vendor/zantknight/yii2-gallery4/migrations
    
  2. Update config/web.php
    return [
        ...
        'modules' => [
            'gallery4' => [
                 'class' => 'zantknight\yii\gallery\Module',
             ],
        ]
    ]
  3. Put this chunk in params.php
     return [
         ...
         'bsVersion' => '4.x',
         ...
     ];
  4. Add this behavior to your model
     ...
     use zantknight\yii\capture\CamCaptureBehavior;
    
     class YourModel extends \yii\db\ActiveRecord
     {
         ...
    
         public function behaviors()
         {
             return [
                 ...
                 [
                     'class' => CamCaptureBehavior::className(),
                     'model' => $this,
                     'fieldName' => 'name'
                 ]
                 ...
             ];
         }
     }
    • fieldName = which field you want to add as picture filename
  5. Put this widget into your view
    <?= \zantknight\yii\capture\CamCaptureWidget::widget([
        'ownerModel' => $model
    ]); ?>
  6. Make a folder "media" under @web
  7. Viola

Screenshots

  • Widget Widget UI
  • Pop-up Capture Pop-up Capture
  • Image Captured to widget Pop-up Capture