Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix #1

Merged
merged 16 commits into from
Aug 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Composer
vendor/
composer.lock
composer.phar
# Composer
vendor/
composer.lock
composer.phar
/nbproject/private/
6 changes: 6 additions & 0 deletions ImageLoadWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'; // алиас к изображениям
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 - может
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"homepage": "http://phpnt.com"
}
],
"require": {
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
"bower-asset/cropper": "*",
Expand Down
4 changes: 4 additions & 0 deletions controllers/ImagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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'],
Expand Down
7 changes: 7 additions & 0 deletions nbproject/project.properties
Original file line number Diff line number Diff line change
@@ -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=.
9 changes: 9 additions & 0 deletions nbproject/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>yii2-cropper</name>
</data>
</configuration>
</project>
8 changes: 5 additions & 3 deletions views/_image.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@
<?php
if ($imagesObject):
foreach($imagesObject as $image):
$imageFileSmall = $frontendUrl.$image->file_small; ?>
$imageFileSmall = $frontendUrl.$image->$previewSize; ?>
<div class="<?= $imageContainerClass ?> image-padding">
<?= Html::button('', ['class' => $buttonDeleteClass, 'onClick' => "window.idImage = '".$image->id."'; deleteImage(event);"]); ?>
<?= Html::img($imageFileSmall, ['class' => $imageClass, 'onclick' => "window.idImage = '".$image->id."'; $('#imageform-image-$id').click();"]); ?>
<?= Html::button($updateImageText, ['class' => 'btm btn-info', 'style' => 'width: 100%;', 'onclick' => "window.idImage = '".$image->id."'; $('#imageform-image-$id').click();"]) ?>
<?= Html::button($updateImageText, ['class' => $buttonClass, 'style' => 'width: 100%;', 'onclick' => "window.idImage = '".$image->id."'; $('#imageform-image-$id').click();"]) ?>
</div>
<?php endforeach;
else:
?>
<div class="<?= $imageContainerClass; ?> image-padding">
<?= Html::img($noImage, ['class' => $imageClass, 'onclick' => "window.idImage = 0; $('#imageform-image-$id').click();"]); ?>
<?= Html::button($createImageText, ['class' => 'btm btn-info', 'style' => 'width: 100%;', 'onclick' => " window.idImage = 0; $('#imageform-image-$id').click();"]) ?>
<?= Html::button($createImageText, ['class' => $buttonClass, 'style' => 'width: 100%;', 'onclick' => " window.idImage = 0; $('#imageform-image-$id').click();"]) ?>
</div>
<?php
endif;
Expand All @@ -92,6 +92,8 @@
echo Html::input('hidden', 'imageData[imageSmallWidth]', $imageSmallWidth);
echo Html::input('hidden', 'imageData[imageSmallHeight]', $imageSmallHeight);
echo Html::input('hidden', 'imageData[createImageText]', $createImageText);
echo Html::input('hidden', 'imageData[buttonClass]', $buttonClass);
echo Html::input('hidden', 'imageData[previewSize]', $previewSize);
echo Html::input('hidden', 'imageData[updateImageText]', $updateImageText);
echo Html::input('hidden', 'imageData[deleteImageText]', $deleteImageText);
echo Html::input('hidden', 'imageData[frontendUrl]', $frontendUrl);
Expand Down
2 changes: 2 additions & 0 deletions views/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
'images_label' => $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,
Expand Down