You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`<Image>` is a UI component that shows an image from an [ImageSource](https://docs.nativescript.org/api-reference/classes/imagesource) or from a URL.
9
+
`<Image>` is a UI component for rendering images. Images can be referenced by URL, resource URL (`res://`), base64 string, font resource (`font://`), [ImageSource](/api/class/ImageSource), and [ImageAsset](/api/class/ImageAsset).
6
10
7
-
<!-- TODO: fix links -->
8
-
<!-- TODO: add flavors -->
9
-
10
-
::: tip
11
+
<!-- ::: tip
11
12
When working with images, consider following [the best practices](/performance.html#image-optimizations).
### Displaying images from the src/assets directory
148
33
149
-
/// flavor vue
34
+
By default all assets placed in the `src/assets` directory (create the directory if it's not present) will be copied to the correct native platform location to be bundled with the app. To reference these images, prefix them with the `~` character, which is an alias pointing to the `src` folder.
Images can be displayed from remote URLs. Depending on the software version of the device, insecure URLs may be blocked (`http://`), it's recommended to always use secure URLs (`https://`).
Gets or sets the source([`ImageSource`](https://docs.nativescript.org/api-reference/classes/imagesource) | [`ImageAsset`](/api-reference/classes/imageasset)) of the image.
81
+
Gets or sets the source.
282
82
283
-
---
83
+
A string can be a `http://`, `https://`, `res://`, `font://` or an absolute path (eg. `~/assets/image.png`).
84
+
85
+
See [`ImageSource`](/api/class/ImageSource) and [`ImageAsset`](/api/class/ImageAsset).
284
86
285
87
### imageSource
286
88
287
89
```ts
288
-
ImageSource.fromUrl(url)
289
-
.then((imageSource:ImageSource) => {
290
-
image.imageSource=imageSource
291
-
})
292
-
.catch((error) => {
293
-
// handle errror
294
-
})
90
+
imageSource: ImageSource
295
91
```
296
92
93
+
Gets or sets the source from an `ImageSource` instance.
Gets or sets the way the image is resized to fill its allocated space. For valid values, see [ImageStretch](https://docs.nativescript.org/api-reference/modules/coretypes.imagestretch).
113
+
Gets or sets the way the image is resized to fill its allocated space.
314
114
315
-
---
115
+
See [`ImageStretchType`](/api/namespace/CoreTypes#imagestretchtype)
316
116
317
117
### loadMode
318
118
319
-
```xml
320
-
<Imagesrc="{{ src }}"loadMode="sync"/>
321
-
119
+
```ts
120
+
loadMode: 'sync'|'async'
322
121
```
323
122
324
-
Gets or sets the loading strategy for the images on the local file system.
123
+
Gets or sets the loading strategy for the images.
124
+
125
+
Default value: `async`.
126
+
325
127
Valid values:
326
128
327
-
-`sync` - blocks the UI if necessary to display immediately. Only recommeded for small icons.
328
-
-`async`(`default`) - will load in the background, may appear with short delay, good for large images. When loading images from web they are always loaded async no regardless `loadMode` value.
129
+
-`sync` - blocks the UI if necessary to display immediately. Only recommeded for small images like icons.
130
+
-`async`- loads in the background, the image may appear with a short delay, good for large images.
329
131
330
-
---
132
+
**Note:** When loading images from the web, they are always loaded `async`.
331
133
332
134
### ...Inherited
333
135
334
-
For additional inherited properties, refer to the [API Reference](https://docs.nativescript.org/api-reference/classes/image).
136
+
For additional inherited properties, refer to the [API Reference](/api/class/Image).
0 commit comments