Closed douglas-srs closed 7 years ago
Hey! Which do you use version of extension?
Latest one, I guess it's 5.1.1, installed today using composer.
Hm... Could you give me dump from $crop_info
model property? And reload page and look at console errors. Property message
from pluginOptions
must have only array string values, no array array string values as you have.
var_dump of $crop_info string(0) ""
Now that you talked about console errors I found out something, after I press the "Crop" button this error shows:
cropbox.js:78 Uncaught TypeError: Cannot read property 'data' of undefined
at HTMLDivElement.<anonymous> (cropbox.js:78)
at HTMLDivElement.dispatch (jquery-1.11.2.min.js:3)
at HTMLDivElement.r.handle (jquery-1.11.2.min.js:3)
at Cropbox._customTrigger (cropbox.js:453)
at Cropbox.crop (cropbox.js:93)
at e.fn.init.$.fn.cropbox (cropbox.js:18)
at HTMLButtonElement.<anonymous> (cropbox.js:73)
at HTMLButtonElement.dispatch (jquery-1.11.2.min.js:3)
at HTMLButtonElement.r.handle (jquery-1.11.2.min.js:3)
You ought to fix messages list:
'messages' => [
'Ajuste a imagem.',
]
After try again.
Fixed the messages list and the problem persists. I set console.log(event) in cb:cropped event and it displays the event with an undefined data attribute. I have no idea what's wrong.
I did some tests with cropbox.js and changed the cb:cropped event to this:
$th.on('cb:cropped', function(event) {
var data = $th.cropbox('getData')[0];
var $img = $('<img />', {
src: data.image,
class: 'img-thumbnail'
});
$(s.croppedContainer).append($img);
$(s.croppedDataInput).val(JSON.stringify($th.cropbox('getData')));
});
This makes it works again but I'm sure this is not the proper way and it will probably break If I add more variants or update the plugin.
For some reason this._customTrigger(EVENT_CB_CROPPED, {data: data}); is not passing the data to the event.
I found out something weird:
$th.on('cb:cropped', function(event) {
console.log(event.detail.data.image);// this prints undefined
console.log(event.originalEvent.detail.data.image);// this prints the image data
var $img = $('<img />', {
src: event.originalEvent.detail.data.image,
class: 'img-thumbnail'
});
$(s.croppedContainer).append($img);
$(s.croppedDataInput).val(JSON.stringify($th.cropbox('getData')));
});
This way it works, looks like some kind of jQuery issue, I found this: https://github.com/jquery/jquery/issues/1867
Maybe you could check if event.detail is undefined and set use event.originalEvent instead.
I made tests with your cropbox configuration. I have all work. I don't know why you have a trouble. Update your jQuery library to 2.2.4 minimum. You have very oldest version of jQuery.
Man... that was it, I'm so sorry for all the trouble, turned out another plugin I installed was using an old version of jQuery, I replaced it with newer jQuery and now it works perfectly, thank you for support and awesome plugin!
Don't worry. Be happy. =)
Hello,
When trying to save an image I'm getting this error. Note: I'm using yii2-user and adding the image to the profile form.
My model:
My View:
My Controller: