PHP code example of sjaakp / yii2-illustrated-behavior
1. Go to this page and download the library: Download sjaakp/yii2-illustrated-behavior library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sjaakp / yii2-illustrated-behavior example snippets
use sjaakp\illustrated\Illustrated;
class <model> extends \yii\db\ActiveRecord {
...
public function behaviors(){
return [
[
"class" => Illustrated::class,
"attributes" => [
"picture" => [ // attribute name of the illustration
... // options for 'picture'
],
... // other illustrations
],
... // other Illustrated options
],
... // other behaviors
];
}
...
}
An ActiveRecord with **Illustrated 2.0** behavior can have one or more
illustrations.
Each illustration has it's own, fixed proportions, so that views of
the ActiveRecord will have a consistent layout.
Each illustration is associated with one attribute in the ActiveRecord
and a corresponding field in the database table. This attribute stores
the filename of the uploaded image. **Illustrated 2.0** uses its own
naming scheme. An uploaded image file name is never longer than eleven
characters.
In its basic operation, **Illustrated 2.0** stores one version of the
uploaded file for each illustration. However, it is possible to make
it store several versions, with different resolutions. This is perfect
for [responsive images](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images)
More information [here](https://css-tricks.com/a-guide-to-the-responsive-images-syntax-in-html/).
----------
## Usage of CropperWidget ##
**CropperWidget** is an [input widget](http://www.yiiframework.com/doc-2.0/yii-widgets-inputwidget.html "Yii API"). It is intended
to upload an illustration. It can be used in an [ActiveForm](http://www.yiiframework.com/doc-2.0/yii-widgets-activeform.html "Yii API")
like this:
use sjaakp\illustrated\CropperWidget;
$form = ActiveForm::begin([
'options' => ['enctype' => 'multipart/form-data'] // important, needed for file upload
]);