diff --git a/.gitignore b/.gitignore index 24856a7..97e4cbb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -# Composer -vendor/ -composer.lock -composer.phar +# Composer +vendor/ +composer.lock +composer.phar +/nbproject/private/ \ No newline at end of file diff --git a/ImageLoadWidget.php b/ImageLoadWidget.php index 38bf042..02903c4 100644 --- a/ImageLoadWidget.php +++ b/ImageLoadWidget.php @@ -33,6 +33,8 @@ class ImageLoadWidget extends Widget public $updateImageText = 'Изменить фото'; public $deleteImageText = 'Удалить фото'; public $headerModal = 'Загрузить аватар'; // заголовок в модальном окне + public $buttonClass = 'btm btn-info'; // класс для кнопок - загрузить/обновить + public $previewSize = 'file_small'; // размер изображения для превью(либо file_small, либо просто file) public $sizeModal = 'modal-lg'; // размер модального окна public $frontendUrl = ''; public $baseUrl = '@webroot'; // алиас к изображениям @@ -153,6 +155,8 @@ public function registerClientScriptMany() image_id: window.idImage, images_num: "$this->images_num", images_label: "$this->images_label", + buttonClass: "$this->buttonClass", + previewSize: "$this->previewSize", images_temp: "$this->images_temp", imageSmallWidth: "$this->imageSmallWidth", imageSmallHeight: "$this->imageSmallHeight", @@ -271,6 +275,8 @@ public function registerClientScriptOne() image_id: window.idImage, images_num: "$this->images_num", images_label: "$this->images_label", + buttonClass: "$this->buttonClass", + previewSize: "$this->previewSize", images_temp: "$this->images_temp", imageSmallWidth: "$this->imageSmallWidth", imageSmallHeight: "$this->imageSmallHeight", diff --git a/README.md b/README.md index c761567..03f5d9b 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,8 @@ use phpnt\cropper\ImageLoadWidget; 'imageSmallHeight' => 750, // высота миниатюры 'imagePath' => '/uploads/avatars/', // путь, куда будут записыватся изображения относительно алиаса 'noImage' => 2, // 1 - no-logo, 2 - no-avatar, 3 - no-img или путь к другой картинке + 'buttonClass'=> 'btm btn-info', // класс кнопки "обновить аватар"/"загрузить аватар" / по умолчанию btm btn-info + 'previewSize'=> 'file', // размер изображения для превью(либо file_small, либо просто file) 'pluginOptions' => [ // настройки плагина 'aspectRatio' => 1/1, // установите соотношение сторон рамки обрезки. По умолчанию свободное отношение. 'strict' => false, // true - рамка не может вызодить за холст, false - может diff --git a/composer.json b/composer.json index a11db7b..311e539 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "homepage": "http://phpnt.com" } ], - "require": { + "require": { "php": ">=5.4.0", "yiisoft/yii2": "*", "bower-asset/cropper": "*", diff --git a/controllers/ImagesController.php b/controllers/ImagesController.php index c0b5060..beec5da 100644 --- a/controllers/ImagesController.php +++ b/controllers/ImagesController.php @@ -49,6 +49,8 @@ public function actionAutoloadImage() 'object_id' => $imageData['object_id'], 'images_num' => $imageData['images_num'], 'images_label' => $imageData['images_label'], + 'buttonClass' => $imageData['buttonClass'], + 'previewSize' => $imageData['previewSize'], 'images_temp' => $imageData['images_temp'], 'imageSmallWidth' => $imageData['imageSmallWidth'], 'imageSmallHeight' => $imageData['imageSmallHeight'], @@ -102,6 +104,8 @@ public function actionDeleteImage() 'object_id' => $imageData['object_id'], 'images_num' => $imageData['images_num'], 'images_label' => $imageData['images_label'], + 'buttonClass' => $imageData['buttonClass'], + 'previewSize' => $imageData['previewSize'], 'images_temp' => $imageData['images_temp'], 'imageSmallWidth' => $imageData['imageSmallWidth'], 'imageSmallHeight' => $imageData['imageSmallHeight'], diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..9e7cd7b --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,7 @@ +include.path=${php.global.include.path} +php.version=PHP_56 +source.encoding=UTF-8 +src.dir=. +tags.asp=false +tags.short=false +web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..1579198 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,9 @@ + + + org.netbeans.modules.php.project + + + yii2-cropper + + + diff --git a/views/_image.php b/views/_image.php index a8b4601..e2c1735 100644 --- a/views/_image.php +++ b/views/_image.php @@ -66,18 +66,18 @@ file_small; ?> + $imageFileSmall = $frontendUrl.$image->$previewSize; ?>
$buttonDeleteClass, 'onClick' => "window.idImage = '".$image->id."'; deleteImage(event);"]); ?> $imageClass, 'onclick' => "window.idImage = '".$image->id."'; $('#imageform-image-$id').click();"]); ?> - 'btm btn-info', 'style' => 'width: 100%;', 'onclick' => "window.idImage = '".$image->id."'; $('#imageform-image-$id').click();"]) ?> + $buttonClass, 'style' => 'width: 100%;', 'onclick' => "window.idImage = '".$image->id."'; $('#imageform-image-$id').click();"]) ?>
$imageClass, 'onclick' => "window.idImage = 0; $('#imageform-image-$id').click();"]); ?> - 'btm btn-info', 'style' => 'width: 100%;', 'onclick' => " window.idImage = 0; $('#imageform-image-$id').click();"]) ?> + $buttonClass, 'style' => 'width: 100%;', 'onclick' => " window.idImage = 0; $('#imageform-image-$id').click();"]) ?>
$widget->images_label, 'images_temp' => $widget->images_temp, 'imageSmallWidth' => $widget->imageSmallWidth, + 'buttonClass' => $widget->buttonClass, + 'previewSize' => $widget->previewSize, 'imageSmallHeight' => $widget->imageSmallHeight, 'imagesObject' => $widget->imagesObject, 'modelImageForm' => $modelImageForm,