Images from image tag not loading in iOS emulator


#22

nice workaround! Worked for me! I was facing this problem


#23

Is there anyone who solved image load problem from a web url?


#24

It’s confusing that when you have root relative paths like /img/blah.jpg it works just fine in the Ionic View app but not in native iOS apps.


#25

Same for me. With Android (real dive) and browser simulator, everything is ok.


#26

I had it like this: background: url(’/…/img/bg.jpg’);

Changed it to: background: url(’…/img/bg.jpg’);

And it worked. So the backslash before the dot was the problem.


#27

If you need your images to work cross-platform. Using content: url() worked best for me.

First copy your image into your working directory.

src/assets/img/

Then set your <img> location in your template.

<!-- home.html -->

<ion-content>
  <img class="logo">
</ion-content> 

Then reference your image from you asset directory from your scss.

// home.scss

.logo {
  content: url('../assets/img/logo.png');
}

This was tested with iOS and Web.


#28

Thank you so much :slight_smile:


#29

Also had this problem. I used the default img path so

src/assets/img/

What worked cross platform for me was this (from the .ts file).

this.postHeaderURL = 'assets/img/imgName.jpg';