Start a new topic

ImageResource from external url

ImageResource from external url

Hello all, I'm programming an application with Wikitude using Phonegap plugin. One part of the app consists on image recognition and a Trackable2DObject. In the imageResource instead of having all the images in the "assets/" folder its mandatory to retrieve it from a database, all the calls to the database are working (using getJSON) and sending to the world with callJavascript correctly but the imageResource is not working or it don't recognize the path.

Here is the method:

loadPath: function loadPathFn(imagePath){



path = World.urlFoto + imagePath; //World.urlFoto is declared in the init function of the world as: urlFoto: "",

newImagePath = JSON.stringify(path);

alert("el path es: " + newImagePath);

$("#fotoromano").attr('src', path );  //this one appends the image in a slider with id=fotoromano to see if there's a problem with the link but it's showing on the slider correctly

var imgInternet = new AR.ImageResource(newImagePath);


imgInternet.onLoaded(function() {

alert("is loaded!");








imagePath is a callJavascript from the index.js outside the world and the alert returns the correct path, the second alert says: el path es: "" with the comas includes because I figured that I need a string so I used JSON.stringify but still not working.

I tried to create a ImageResource ("") but it didn't worked and tried without the newImagePath = JSON.stringify(path);


Thanks for helping.




Here is the rest of the code:


createOverlays: function createOverlaysFn() {


alert("carga OverLays");

this.tracker2 = new AR.Tracker("assets/");


var overlayTwo = new AR.ImageDrawable(imgInternet, 1, {

offsetX: 0.1,

offsetY: -0.1,

scale: 0.7



var pageOne = new AR.Trackable2DObject(this.tracker2, "*", {

drawables: {

cam: overlayTwo






PS: With an image in assets/ folder it's working (but I need to store the image (or images) in my Database.


EDIT: I added the code in bold to see what is exactly happening, it gots stuck on the onLoaded() function which I think it means that the world can't load the image correctly but getUri() method is returning the valid url to the image

You don't need to use JSON.stringify, since your URL is already a string.
Login or Signup to post a comment