Reputation: 93
I need to display images like gif, FontAwesome icons in toast notification but these system-defined methods not supporting it. Is there any other way around?
The URL I am receiving is this - https://media.tenor.com/images/036d52936bbc66e8afca81259478b1c5/tenor.gif and below is the code. I am able to display all other images having extension jpg/png.
ToastContent toastContent = new ToastContent() { Duration = duration, Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = title, HintMaxLines = 1 },
new AdaptiveImage()
{
Source = imageUrl
},
},
AppLogoOverride = new ToastGenericAppLogo()
{
Source = feedObject.sender_image,
HintCrop = ToastGenericAppLogoCrop.Default
}
}
},
Launch = Constants.NOTIFICATIONLAUNCHNOTIIFCATION + "=" + feedObject.mlink
};
I am getting FontAwesome's icon in this format. I can parse it using XML reader but then how can I convert these icons into png?
"far fa-address-card", "background-color"=>"rgb(220, 224, 231)", "color"=>"rgb(0, 0, 0)"}\" />
Upvotes: 1
Views: 528
Reputation: 7727
I tested the picture you gave, when it is local, it can be displayed normally. According to the content of the document:
If an image exceeds the file size, or fails to download, or times out, the image will be dropped and the rest of the notification will be displayed.
The file size you provided is 2.82MB. In version 16299 and later, it can be displayed normally, but in the previous version, it will fail to load because it exceeds the limit. The image size after 16299 is limited to 3MB, before it was 200KB.
If your version meets the requirements, the reason why the picture cannot be displayed should be a network problem. .jpg
pictures are much smaller than .gif
pictures and easy to load. The .gif
image may not be loaded within the specified time due to its large size and slow internet speed, so it will stop loading the image.
If you often want to use this image, you can save it locally and load it through a local link, such as ms-appxdata:///local/myimage.gif
.
In the UWP notification, although XML is used, it does not have a class like HTML, and there is no corresponding CSS. Your FontAwesome reference code does not apply to Toast Notification.
You don't have to convert the code to a png image. You can find the corresponding icon on the official website of FontAwesome and download the Svg image. If your system version is above 16299, you can directly use svg pictures, if not, or if you want to do other processing on svg pictures, you can use online tools to convert.
Upvotes: 0