Use Platform Specific Images in Ionic


#1

Hi All,

I have an application that has a lot of images. These images and their sizes vary with device. I cannot programmatically assign a value to each image / icon because thats a huge amount of effort for me.

I am looking at a smarter way for the app to identify the platform for which the app is rendered and pick the correct images.

Any ideas / solutions?

Regards


#2

In addition to the above, I also wanted to understand how to manage images for various resolutions of devices (xhdpi, xxhdpi) etc.


#3

So if you’re looking for a programatic way to handle images depending on the platform, you could look to this directive for inspiration

Now this one will change the icon based on the platform, but you can adapt it to work for images.


#4

Thanks for this. I am not looking at a programmatic way. I wanted to understand if there is a feature provided (maybe by Sass / css / any other tech.) wherein I can save images in respective folder (and maybe even map folder names with device resolutions), and the appropriate images are picked as per device resolution.

For example, how does iPhone know if it has to pick the image abc.png or abc@2x.png or abc@3x. png?