sjaakp / yii2-illustrated-behavior

Adds image to ActiveRecord
http://www.sjaakpriester.nl/software/illustrated
MIT License
43 stars 17 forks source link

Update scenario #10

Closed xavsio4 closed 8 years ago

xavsio4 commented 9 years ago

Hello, The extension works fine in a "create" scenario, but how to display the image in the uploader widget in an update scenario ?

Thanks

xavier

xavsio4 commented 9 years ago

This is what I've done to make it work. I don't know if it is the right thing to do.

<?php if (!$model->isNewRecord) $this->registerJs(' $(\'#w1 .cropper\').cropper(\'loadImage\', \'../../../storage/'.$model->tag_photo.'\'); ', View::POS_READY); ?>

sjaakp commented 9 years ago

This limitation is by design.

I’ve put some thought into an update scenario, and I see one big problem with it: the source image isn’t available anymore. Only the cropped image is. Therefore, a second cropping can only yield an even more cropped image, never a less cropped one. That’s why I refrained from an update scenario. In my view, cropping is part of the upload process. If the user wants to modify the crop, she has to upload the image again.

It’s easy enough to load the cropped image into the cropper control, as you’ve shown. However, IllustratedBehavior in its current form doesn’t have the capability to ‘recrop’ a server stored image. In fact, it doesn’t do anything with the cropping information.


Sjaak Priester

mailto:sjaak@sjaakpriester.nl sjaak@sjaakpriester.nl

Van: xavier [mailto:notifications@github.com] Verzonden: dinsdag 7 juli 2015 15:23 Aan: sjaakp/yii2-illustrated-behavior Onderwerp: Re: [yii2-illustrated-behavior] Update scenario (#10)

This is what I've done to make it work. I don't know if it is the right thing to do.

isNewRecord) $this->registerJs(' $(\'#w1 .cropper\').cropper(\'loadImage\', \'../../../storage/'.$model->tag_photo.'\'); ', View::POS_READY); ?>

— Reply to this email directly or view it on GitHub https://github.com/sjaakp/yii2-illustrated-behavior/issues/10#issuecomment-119201459 . https://github.com/notifications/beacon/AFU71voAHTg39Hvjfr16UUwFyq-3ozz4ks5oa8pKgaJpZM4FTdTf.gif