krish-dev / cordova-plugin-k-imagecropper

Cordova plugin for image cropping with custom aspect ratio.
18 stars 13 forks source link

In iOS, cropping new image returned old image path which showed incorrect image. [Proposed Solution Inside] #8

Open necixy opened 5 years ago

necixy commented 5 years ago

Original library was great in every manner. In iOS, there was a small bug that cropping new image returned old image path which showed incorrect image. To make file name unique and avoid name mismatch, adding intervalString as an extra layer in the file name for iOS and it solved problem (at least for me).

Following code is added in KImageCropper.m file, inside tempFilePath function:

NSTimeInterval  today = [[NSDate date] timeIntervalSince1970];
NSString *intervalString = [NSString stringWithFormat:@"%f", today];
filePath = [NSString stringWithFormat:@"%@/%@%03d_%@.%@", docsPath, CDV_PHOTO_PREFIX, i++, intervalString , extension];

Made a little forked version to address above issue and that can be found here: https://github.com/necixy/cordova-plugin-k-imagecropper

Feel free to use forked version this if you're facing the same bug in the original library.