1. Go to this page and download the library: Download aquy/yii2-gallery-manager 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/ */
aquy / yii2-gallery-manager example snippets
class m150318_154933_gallery_ext
extends aquy\gallery\migrations\m140930_003227_gallery_manager
{
}
public function actions()
{
return [
'galleryApi' => [
'class' => GalleryManagerAction::className(),
// mappings between type names and model classes (should be the same as in behaviour)
'types' => [
'product' => Product::className()
]
],
];
}
if ($model->isNewRecord) {
echo 'Can not upload images for new record';
} else {
echo GalleryManager::widget(
[
'model' => $model,
'behaviorName' => 'galleryBehavior',
'apiRoute' => 'product/galleryApi',
'async' => false
]
);
}
foreach($model->getBehavior('galleryBehavior')->getImages() as $image) {
echo Html::img($image->getUrl());
}