Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Customize Image Source URL path

$
0
0

Hi! This is my first question in the forums and I got to this point because I've found no help anywhere.

The story is as follows:

  • I get an object from web that has an ImageURL property
  • I have an online resizer (imagine something like myresizer.com/image=[ImageURL]&size=[size] that will return a resized image)
  • I have in my Xaml something like: <Image Source="{Binding ImageURL}">

Now, I want to change that source to a string something like "myresizer.com/image="imageurl"&size"300""

I don't know many ways to do this, if you have a better idea, please let me know, but what I thought of the following solution:

  • Having a class (named ImageResized) that inherits from "Xamarin.Forms.Image" and overrides the source url to something like:
    (pseudocde) Source = string.format{"myresizer.com/image=\"{0}\"&size=\"{1}\"", Source, "300");

  • In my xaml I use ImageResized instead of image like this: <local:ImageResized Source="{Binding ImageURL}>"

Once I have that, I guess that adding a new property like the size to my ImageResized wouldn't be much trouble, and if you can help me with that so I can do <local:ImageResized Source="{Binding ImageURL} Size="{Binding ImageSize}>" I will really appreciate!

Thank you in advance for any help!


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>