Closed nihaha closed 7 years ago
sounds weird, no suggestions at the moment…
can you add more details about you setup?
Yes, I've tried both Firefox and Chorme and their private modes, no luck.
This is how I render widget:
<?php
if ($model->isNewRecord) {
echo 'Can not upload images for new record';
} else {
echo GalleryManager::widget(
[
'model' => $model,
'behaviorName' => 'galleryBehavior',
'apiRoute' => 'product/galleryApi'
]
);
}
?>
This is my ProductController:
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(),
'product_reviews' => Product::className()
]
],
'error' => [
'class' => 'yii\web\ErrorAction',
],
];
}
and a model Product:
public function behaviors()
{
return [
'galleryBehavior' => [
'class' => GalleryBehavior::className(),
'type' => 'product',
'extension' => 'jpg, png, jpeg',
'directory' => Yii::getAlias('@webroot') . '/upload',
'url' => Yii::getAlias('@web') . '/upload',
'versions' => [
'small' => function ($img) {
/** @var \Imagine\Image\ImageInterface $img */
return $img
->copy()
->thumbnail(new \Imagine\Image\Box(200, 200));
},
'medium' => function ($img) {
/** @var \Imagine\Image\ImageInterface $img */
$dstSize = $img->getSize();
$maxWidth = 800;
if ($dstSize->getWidth() > $maxWidth) {
$dstSize = $dstSize->widen($maxWidth);
}
return $img
->copy()
->resize($dstSize);
},
]
],
];
}
Directory 'upload' does exist and I can upload files there via other extensions (ElFinder, Dropzone).
That's totally weird due to I have no error messages whatsoever.
code looks ok…
what do you see in network tab in inspector?
Ok, I believe I've located the problem. Do not waste your time, this is some kind of js conflicts I believe. I will let you know when I'll figure it out. Thanks for such a short response time!
Ok, I've solved my issue. Now everything is working fine. That indeed was a js conflict with one of my template built-in scripts for displaying a dashboard ('ecomDashboard.js').
BTW, when I try to delete an image all I see is alert('OK') and the image stays until I refresh. Is this a default behavior?
BTW, when I try to delete an image all I see is alert('OK') and the image stays until I refresh. Is this a default behavior?
No, image should be removed immediately after server response. And there is no confirmation. Previously there was confirmation but it was eventually removed as not useful:
https://github.com/zxbodya/yii2-gallery-manager/blob/master/assets/jquery.galleryManager.js#L157
About OK
in alert - looks strange, alert with error message is should be displayer if message is not OK
:
https://github.com/zxbodya/yii2-gallery-manager/blob/master/assets/jquery.galleryManager.js#L140
This is what I'm getting trying to delete image: http://joxi.ru/KAg86dQs4OPRer Ajax 200, all ok, but the image will be on page until I hit refresh.
Check what is in Yii::$app->request->post('id')
- it should be array of ids to remove, but somehow it is not
Looks fine to me http://joxi.ru/n2YkPvGTo0PGqr
it is used in call to delete images, which errors in your case: https://github.com/zxbodya/yii2-gallery-manager/blob/master/GalleryManagerAction.php#L65
maybe there is something in your app, that is updating parameter in request before it is passed to deleteImages method
Ok, I'll check. Thanks again!
Can't figure out why the widget in my form doesn't load images. After choosing an image from my HDD the window just closes and nothing happens. At all. I have no errors, no warnings, no ajax requests has been sent. Two js files from module are included, widget renders fine. Also, if I try to drag-n-drop image on top of the widget no message box appears (no gray dotted box Drop File Here...). Console is clean, no errors. Can you, please, suggest any possible reasons? Thanks.