3

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?

Sandra Rossi
  • 9,036
  • 2
  • 18
  • 39
www40
  • 245
  • 1
  • 7
  • 19

2 Answers2

5

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...

dotchuZ
  • 2,602
  • 11
  • 35
  • 61
  • Your suggestion leeds to: `https://:/sap/bc/ui5_ui5/ui2/ushell/shells/abap/img/greendot.png`, any other ideas? (I am loading it from the Fiori Launchpad, so i have just the Component.js) – www40 Oct 23 '15 at 21:05
3
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.

www40
  • 245
  • 1
  • 7
  • 19