Skip to content

Commit 448cf93

Browse files
author
phpNT
authored
Merge pull request #1 from woodroow/bugfix
Bugfix
2 parents 65b36b6 + 70c3478 commit 448cf93

9 files changed

+41
-8
lines changed

.gitignore

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Composer
2-
vendor/
3-
composer.lock
4-
composer.phar
1+
# Composer
2+
vendor/
3+
composer.lock
4+
composer.phar
5+
/nbproject/private/

ImageLoadWidget.php

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class ImageLoadWidget extends Widget
3333
public $updateImageText = 'Изменить фото';
3434
public $deleteImageText = 'Удалить фото';
3535
public $headerModal = 'Загрузить аватар'; // заголовок в модальном окне
36+
public $buttonClass = 'btm btn-info'; // класс для кнопок - загрузить/обновить
37+
public $previewSize = 'file_small'; // размер изображения для превью(либо file_small, либо просто file)
3638
public $sizeModal = 'modal-lg'; // размер модального окна
3739
public $frontendUrl = '';
3840
public $baseUrl = '@webroot'; // алиас к изображениям
@@ -153,6 +155,8 @@ public function registerClientScriptMany()
153155
image_id: window.idImage,
154156
images_num: "$this->images_num",
155157
images_label: "$this->images_label",
158+
buttonClass: "$this->buttonClass",
159+
previewSize: "$this->previewSize",
156160
images_temp: "$this->images_temp",
157161
imageSmallWidth: "$this->imageSmallWidth",
158162
imageSmallHeight: "$this->imageSmallHeight",
@@ -271,6 +275,8 @@ public function registerClientScriptOne()
271275
image_id: window.idImage,
272276
images_num: "$this->images_num",
273277
images_label: "$this->images_label",
278+
buttonClass: "$this->buttonClass",
279+
previewSize: "$this->previewSize",
274280
images_temp: "$this->images_temp",
275281
imageSmallWidth: "$this->imageSmallWidth",
276282
imageSmallHeight: "$this->imageSmallHeight",

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ use phpnt\cropper\ImageLoadWidget;
6969
'imageSmallHeight' => 750, // высота миниатюры
7070
'imagePath' => '/uploads/avatars/', // путь, куда будут записыватся изображения относительно алиаса
7171
'noImage' => 2, // 1 - no-logo, 2 - no-avatar, 3 - no-img или путь к другой картинке
72+
'buttonClass'=> 'btm btn-info', // класс кнопки "обновить аватар"/"загрузить аватар" / по умолчанию btm btn-info
73+
'previewSize'=> 'file', // размер изображения для превью(либо file_small, либо просто file)
7274
'pluginOptions' => [ // настройки плагина
7375
'aspectRatio' => 1/1, // установите соотношение сторон рамки обрезки. По умолчанию свободное отношение.
7476
'strict' => false, // true - рамка не может вызодить за холст, false - может

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"homepage": "http://phpnt.com"
1717
}
1818
],
19-
"require": {
19+
"require": {
2020
"php": ">=5.4.0",
2121
"yiisoft/yii2": "*",
2222
"bower-asset/cropper": "*",

controllers/ImagesController.php

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public function actionAutoloadImage()
4949
'object_id' => $imageData['object_id'],
5050
'images_num' => $imageData['images_num'],
5151
'images_label' => $imageData['images_label'],
52+
'buttonClass' => $imageData['buttonClass'],
53+
'previewSize' => $imageData['previewSize'],
5254
'images_temp' => $imageData['images_temp'],
5355
'imageSmallWidth' => $imageData['imageSmallWidth'],
5456
'imageSmallHeight' => $imageData['imageSmallHeight'],
@@ -102,6 +104,8 @@ public function actionDeleteImage()
102104
'object_id' => $imageData['object_id'],
103105
'images_num' => $imageData['images_num'],
104106
'images_label' => $imageData['images_label'],
107+
'buttonClass' => $imageData['buttonClass'],
108+
'previewSize' => $imageData['previewSize'],
105109
'images_temp' => $imageData['images_temp'],
106110
'imageSmallWidth' => $imageData['imageSmallWidth'],
107111
'imageSmallHeight' => $imageData['imageSmallHeight'],

nbproject/project.properties

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include.path=${php.global.include.path}
2+
php.version=PHP_56
3+
source.encoding=UTF-8
4+
src.dir=.
5+
tags.asp=false
6+
tags.short=false
7+
web.root=.

nbproject/project.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://www.netbeans.org/ns/project/1">
3+
<type>org.netbeans.modules.php.project</type>
4+
<configuration>
5+
<data xmlns="http://www.netbeans.org/ns/php-project/1">
6+
<name>yii2-cropper</name>
7+
</data>
8+
</configuration>
9+
</project>

views/_image.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@
6666
<?php
6767
if ($imagesObject):
6868
foreach($imagesObject as $image):
69-
$imageFileSmall = $frontendUrl.$image->file_small; ?>
69+
$imageFileSmall = $frontendUrl.$image->$previewSize; ?>
7070
<div class="<?= $imageContainerClass ?> image-padding">
7171
<?= Html::button('', ['class' => $buttonDeleteClass, 'onClick' => "window.idImage = '".$image->id."'; deleteImage(event);"]); ?>
7272
<?= Html::img($imageFileSmall, ['class' => $imageClass, 'onclick' => "window.idImage = '".$image->id."'; $('#imageform-image-$id').click();"]); ?>
73-
<?= Html::button($updateImageText, ['class' => 'btm btn-info', 'style' => 'width: 100%;', 'onclick' => "window.idImage = '".$image->id."'; $('#imageform-image-$id').click();"]) ?>
73+
<?= Html::button($updateImageText, ['class' => $buttonClass, 'style' => 'width: 100%;', 'onclick' => "window.idImage = '".$image->id."'; $('#imageform-image-$id').click();"]) ?>
7474
</div>
7575
<?php endforeach;
7676
else:
7777
?>
7878
<div class="<?= $imageContainerClass; ?> image-padding">
7979
<?= Html::img($noImage, ['class' => $imageClass, 'onclick' => "window.idImage = 0; $('#imageform-image-$id').click();"]); ?>
80-
<?= Html::button($createImageText, ['class' => 'btm btn-info', 'style' => 'width: 100%;', 'onclick' => " window.idImage = 0; $('#imageform-image-$id').click();"]) ?>
80+
<?= Html::button($createImageText, ['class' => $buttonClass, 'style' => 'width: 100%;', 'onclick' => " window.idImage = 0; $('#imageform-image-$id').click();"]) ?>
8181
</div>
8282
<?php
8383
endif;
@@ -92,6 +92,8 @@
9292
echo Html::input('hidden', 'imageData[imageSmallWidth]', $imageSmallWidth);
9393
echo Html::input('hidden', 'imageData[imageSmallHeight]', $imageSmallHeight);
9494
echo Html::input('hidden', 'imageData[createImageText]', $createImageText);
95+
echo Html::input('hidden', 'imageData[buttonClass]', $buttonClass);
96+
echo Html::input('hidden', 'imageData[previewSize]', $previewSize);
9597
echo Html::input('hidden', 'imageData[updateImageText]', $updateImageText);
9698
echo Html::input('hidden', 'imageData[deleteImageText]', $deleteImageText);
9799
echo Html::input('hidden', 'imageData[frontendUrl]', $frontendUrl);

views/view.php

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
'images_label' => $widget->images_label,
2222
'images_temp' => $widget->images_temp,
2323
'imageSmallWidth' => $widget->imageSmallWidth,
24+
'buttonClass' => $widget->buttonClass,
25+
'previewSize' => $widget->previewSize,
2426
'imageSmallHeight' => $widget->imageSmallHeight,
2527
'imagesObject' => $widget->imagesObject,
2628
'modelImageForm' => $modelImageForm,

0 commit comments

Comments
 (0)