Hello.
I am using Cordova Webview to select a photo from the album, save it locally, and then pass the saved path to the web for display.
It displayed correctly up to OS 26.3.x, but starting from OS 26.4.x, I am unable to retrieve images from local paths. Part displayed in Cordova Webview
<img src="file:///var/mobile/Containers/Data/Application/.../tmp/cdv_photo_006.jpg" width="auto" height="auto" alt="" draggable="false" id="box" class="sc-bczRLJ sc-gsnTZi eVuMcq blHpFC" style="object-fit: contain; width: 100%; max-height: 368px;">
I have also confirmed the existence of the corresponding file in the src path.
Are there any known bugs or solutions?
Thank you.
Thanks for your post and your insight on this one.
Based on the code snippet and the behavior you are describing in WKWebView, I’m sure the issue is as you describe caused by appending a query string (? + timestamp) to a file:// URI.
Xcode does not handle HTML and modifies the WKWebView. Is after the tools and developers to set the HTML to display on the WKWebView.
Unlike http:// or https:// URLs, file:// URIs do not natively support query parameters, appending ?1776643364151 causes the system to look for a file literally named profile_image.jpg?1776643364151 on the disk. Because that file doesn't exist, WKWebView returns a broken image?
I believe is important to highlight the 3rd party tool you are using is the one that generates the custom HTML?
When loading your local HTML file, and does not ensure the allowingReadAccessTo parameter points to a directory high enough in the file tree to encompass both your HTML files and your saved images.
I suggest you first check with the third-party tool, as they’re the ones creating the output. Of course, you’ll still need to decide what you want to inject into the WKWebView.
Albert Worldwide Developer Relations.