maui icon indicating copy to clipboard operation
maui copied to clipboard

Load an SVG from web URL

Open jennablackwell opened this issue 2 years ago • 3 comments

Description

I would like to have the image control have the ability to load an SVG from a web URL. In Xamarin Forms I was able to do this with FFImageLoader, but this library doesn't support . net MAUI. I haven't seen an alternative for this.

Public API Changes

<Image Source="http://www.my.com/img.svg" /> 

Intended Use-Case

I want to be able load a list of records from my database dynamically which each links to an svg file hosted on my azure blob. I don't want to use pngs due to not being able to change it's color and worry about sizing. I don't want to embed in the app because then I cannot dynamically change the color of the image based on whether light theme or dark theme.

jennablackwell avatar Sep 12 '22 02:09 jennablackwell

workaround might be downloading the svg and loading from MemoryStream from memory

janseris avatar Sep 12 '22 07:09 janseris

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Sep 12 '22 14:09 ghost

Have you found any workaround for this? I've tried loading from file, but doesn't work.

drossoft avatar Mar 11 '23 16:03 drossoft

I think what you're looking for is the ImageResourceConverter as shown in this sample. This has been built-in functionality since before this issue was created. I had no trouble finding it, maybe search engines have indexed it better since then?

EDIT: Ah, it's not built-in into MAUI, but into the CommunityToolkit. Personally, I see no reason not to use both, but that explains why some people might not have noticed. They might've thought it was a different library and did not apply to their situation.

Ghostbird avatar Mar 21 '23 09:03 Ghostbird

@Ghostbird

The ImageResourceConverter you're talking about doesn't seem to have anything to do with the issue at hand here. The issue surrounds loading .svg files form a remote source. The ImageResourceConverter converts embedded image resource ID to its ImageSource.

I'm also looking for a way to load SVG files from a URL and haven't found one yet.

GlacierFox avatar Jun 08 '23 15:06 GlacierFox

@GlacierFox Apologies, would the MediaSourceConverter work for you? Maybe that's the one I was thinking of. I don't remember, it's been a while.

Ghostbird avatar Jun 08 '23 17:06 Ghostbird

I made this: https://gist.github.com/andressbarajas/c2248d5925087f5b769aacb9af8f74a8

It doesnt load from a URL but it does load SVG data as a string ("<svg ..... ").

andressbarajas avatar Sep 19 '23 19:09 andressbarajas

To load an SVG from a web URL, using SvgCachedImage from https://www.nuget.org/packages/FFImageLoading.Maui works. To use, reference FFImageLoading in xaml file using below. xmlns:ffimageloading="clr-namespace:FFImageLoading.Maui;assembly=FFImageLoading.Maui"

jayesh94 avatar Jun 19 '24 06:06 jayesh94