You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "jcesarmobile (Jira)" <ji...@apache.org> on 2019/10/19 23:00:03 UTC
[jira] [Closed] (CB-11835) Cordova image URIs may be cached
[ https://issues.apache.org/jira/browse/CB-11835?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
jcesarmobile closed CB-11835.
-----------------------------
Resolution: Fixed
Might be fixed by https://github.com/apache/cordova-plugin-camera/pull/306
If not, please, report a new issue on https://github.com/apache/cordova-plugin-camera/issues
> Cordova image URIs may be cached
> --------------------------------
>
> Key: CB-11835
> URL: https://issues.apache.org/jira/browse/CB-11835
> Project: Apache Cordova
> Issue Type: Bug
> Components: cordova-plugin-camera
> Affects Versions: 4.2.1
> Environment: Reproduced on iPhone 6, iPad Pro, and iPad 3, with iOS 9.3.4.
> Reporter: Jacob Weber
> Priority: Minor
>
> This is not strictly a Cordova bug, but I think it should be added to the documentation, as it could help people avoid a lot of pain.
> If you call camera.cleanup(), and then start calling camera.getPicture() with the default Camera.destinationType.FILE_URI, Cordova will return image URIs with sequential numbers starting at 1, like "cdv_photo_001.jpg".
> If you then repeat these steps, Cordova will start the numbering over, and return the same sequence of image URIs.
> If you're setting an <img> tag's source to the URIs, as in the documented examples, the browser may use cached images the second time. As a result, you might take a picture, and then see an image of a picture you took a while ago.
> I would suggest changing the examples with {{img.src = imageURI}} to something like {{img.src = imageURI + "?v=" + new Date().getTime()}}, so it avoids the cached image.
> Here is a test case. Create a project and add the following. When you click Capture the first time, and take a picture, you'll see the correct preview. When you click it a second time, and take a different picture, you'll still see the original picture's preview.
> {code}
> // config.xml
> ...
> <engine name="ios" spec="4.2.1" />
> <plugin name="cordova-plugin-camera" spec="2.2.0" />
> {code}
> {code}
> // index.html
> <button id="capture">Capture</button>
> <img id="preview" />
> <script>
> document.getElementById("capture").addEventListener("click", function() {
> navigator.camera.cleanup();
> navigator.camera.getPicture(
> function(imageURI) {
> document.getElementById("preview").src = imageURI;
> },
> function() {},
> {
> targetWidth: 200,
> targetHeight: 200
> }
> );
> });
> </script>
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org