www40
www40

Reputation: 285

SAPUI5 load image in Fiori app, image path was changed

i am trying to load a image in my fiori app. The image is located in /webapp/img/greendot.jpg like this:
enter image description here

But then i deploy my app to my ABAP-Repository the path changed to:

https://<server>:<port>/sap/bc/ui5_ui5/sap/my_application/~CD103454ACB782CF74F8A2339BE67CE1~5/img/greendot.png

How can i get this path so i can load my image?

Upvotes: 4

Views: 10737

Answers (2)

www40
www40

Reputation: 285

var sRootPath = jQuery.sap.getModulePath("<package_name>");
var sImagePath = sRootPath + "/img/greendot.png";

seems to work, but i don't know if this is the "correct" way to solve this.

Upvotes: 4

dotchuZ
dotchuZ

Reputation: 2641

Then you are loading it wrong, you should reference the SRC-property to your relative path: "/img/greendot.png" or try "./img/greendot.png"

var img = new sap.m.Image({
   src : "./img/greendot.png",
});

there is no need during runtime to request any backend-paths...

Upvotes: 5

Related Questions