You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/02/11 14:55:01 UTC

[GitHub] [cordova-plugin-wkwebview-engine] varavindraj opened a new issue #187: Cannot set base64 image on WKWebview using evaluateJavascript method iOS platform

varavindraj opened a new issue #187:
URL: https://github.com/apache/cordova-plugin-wkwebview-engine/issues/187


   I have a HTML file which contains local resource files such as css, js files inside its content. These local resource files are in zip format. My app uses Cordova's WKWebView to display this html file on wkwebview. I m trying to upload an image in one of the html image element on WKWebView which is saved locally and is converted to base64 string but its not updating the image. I have a html image tag in local html like this.
   
   `<img id='image' style='display: block; height: 100%; width:100%; margin:0 auto;' />
   `
   I update the image using evaluateJavascript method of WkWebView like below
   ```
   NSData *imageData = UIImagePNGRepresentation(image);
   NSString *base64Str = [imageData base64EncodedStringWithOptions:0];     
   NSString *js = [NSString stringWithFormat:@"document.getElementById('image-id').src='data:image/png;base64,%@'",base64Str];
   [self.wkWebView evaluateJavaScript:js completionHandler:nil];
   ```
   
   This is suppose to add the image on the image tag element but it does nothing. I tried this in normal WKWebView and it updates the image without any problem.
   
   This in iOS, Objective C code. We are seeing this issue in all apple devices. 
   
   I am using Cordova version 5.0.0
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org