I have a ArtistPage.ux in the Pages/ folder and I want to load some images from the Assets/ folder.
ArtistPage.ux:
...
// Panel class used to show Artists Images in feed
<Panel ux:Class="ArtistCard" >
<FileSource ux:Property="ArtistImageFile" />
<Panel Width="100%" Height="150" >
<Image ux:Name="artistImage" File="{ReadProperty ArtistImageFile}" />
</Panel>
</Panel>
...
// UX to display feed
<ScrollView Margin="0,0,5,0" >
<StackPanel>
<Each Items="{artist_data}">
<ArtistCard ArtistImageFile="{image}" Margin="5,5,5,5" />
</Each>
</StackPanel>
</ScrollView>
...
ArtistPage.js:
...
// Observable to be exported
var artist_data = Observable();
// Arrays with actual data
// Since this file is in Pages, I go up one folder in order to get to Assets hence '../Assets/logo.jpg'
var artist_image = ["../Assets/logo.jpg",...]
// Populating observable with data
for( var i = 0; i < artist_image.length; ++i ) {
artist_data.add( {
'image' : artist_image[i],
});
}
module.exports = {
artist_data, artist_data
}
...
Project file:
"Includes": [
"*",
"Assets/*.jpg:Bundle"
]
When I run the code, this is the error I get for the images:
Most likely, the images are corrupted or there is another technical reason why they can’t be read. Note that this might, and probably will, manifest differently on local preview, iOS and Android, since the platforms have different ways to handle supported file formats.
What you just wrote tells us exactly one thing: the first image is perfectly fine, and can be shown. One of the others is likely broken. Check them one-by-one!
In that case, please prepare a reliable, complete, minimal reproduction that we could run on our machines. A Fuse project in a .zip would work nicely for that.
var artist_image = ["../Assets/logo.jpg",...]
// change to this
var artist_image = ["Assets/logo.jpg",...]
My guess, that when images are loaded from UX you need to specify the relative path like ../image.jpg, but images loaded from JavaScript looking for app root. That’s why you need to use an absolute path for resources.