ZSSRichTextEditor
ZSSRichTextEditor copied to clipboard
Image Insertion from phone(UIImage Picker)
Its a feature request. I want to import pictures from my phone or take a picture from camera and add it. Can you help me?
What do you propose for hosting the image? Just setting it with a base64 string, or uploading it somewhere? Or, do you mean saving the image locally in your app and referring to it?
For image -
- Let the user select an image or click an image.
- It gets saved in a separate folder under the app name.
- The images get saved under a folder and its path is provided in the html through which image gets loaded in the html.
"optional" but a very important and a cool feature 4. a. Now if user has to host the image(as in my case) somewhere, he can just host it and get the image url. b. So, there should be a method that helps the user to replace the "earlier folder path" to the "new url link"
Being able to insert an image/video from camera roll or whatever they are calling it now would be perfect. I would like to be able to then send it as an email but that's a different issue.. !!
Just wanted to say thanks as well for all the hard work put into this, it is appreciated.
But I think we still struggle with the issue of where to store this image. ZSSRichTextEditor
can be used for a number of different things.
If it was being used to edit HTML that will be uploaded to a server, where do we save the image? (I am not going to write functionality to upload image to a server.)
If the intention is locally in the app, would we just refer to image saved within the app? Or, should it just be converted to base64 as some other small editors do?
An option would be to use the Cloud App API to upload and store the images...
See what I am doing is implementing it on Parse. So I can help you with the the small piece of code that should solve your purpose -
- (void)uploadPhoto:(UIImage *)photo {
if (photo) {
PFFile * file = [PFFile fileWithData:UIImageJPEGRepresentation(photo, 0.5f)];
[file saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
// at this point file should have it's URL properly populated
NSString * url = file.url;
NSLog(@"%@", url);
[self focusTextEditor];
[self insertHTML:[NSString stringWithFormat:@"<img src=\"%@\">", url]];
}];
}
}
But, If you don't want to do any uploading, you can give us an example where this HTML can be saved locally and the images(whether taken from camera or from Picture Library) can be populated.
If you don't understand any part, do let me know. :)
It would be nice if it instead of an alert view to insert an image url it went to the camera with a link to device photos and then allowed us to set a delegate to handle the result of the image selection. Users using it as an html editor could insert heir upload sequence there or parse or cloud or what have you
PFFile What's this?
@nnhubbard I think he means to download image for only once and load it from device (not the Internet) from now on, which leads to save the cellular flow and time.
@zhouxiaowei it's a Parse File. Look into parse.com open source library. It's a great tool for applications which are powered by online data.
[self focusTextEditor];
[self insertHTML:[NSString stringWithFormat:@"<img src=\"%@\">", @"http://fun.youth.cn/yl24xs/201704/W020170406358321645876.jpg"]];
Why is insert pictures in the end, not in the position of the cursor?