AI OnAI Off
Hi Lee,
Using your Image object as described above, your can get the url by calling ImageGalleryHandler.Instance.GetThumbnail(...) like this:
if (portrait != null)
{
var thumb = ImageGalleryHandler.Instance.GetThumbnail(portrait, portrait.Width, portrait.Height, ThumbnailFormat.Exact);
if (thumb != null)
string imageUrl = new UrlBuilder(thumb.Url).Uri;
}
You should take a close look at the GetThumbnail method as it has several overloads, and you might want to use a difference one than the one I've used in this example. In this piece of code, I've retrieved the image in it's original size, you can also choose to retrieve it in a different size (for instance as a thumbnail).
Also, if profile images need to be approved, you should add a check to see if the image has been approved before exposing it :)
Hope this helps!
Karoline
Thank you so much, Karoline! Great answer!
This is just what I needed to get me started in the right direction. :-)
I'm working on an integration with another web site and in doing so need to expose the absolute HTTP URL to a user's portrait image. So far I have found out how I can get at user's EPiServer.Community.ImageGallery.Image object (if the user has a profile image, else it's null) by calling:
Image portrait = MyPageHandler.Instance.GetMyPage(CurrentUser).Portrait;
This returns the correct Image object. However, getting a URL to it is proving to be somewhat arkward. The property 'Image.AbsolutePath' is returning
something that looks similar to the physical directory path, but not quite. From what I can see it looks like the returned filename is being appended with the author's ID inserterd after the orignal filename, but before the file type extension, or so it seems...
So is there any simple way to get a URL to the portrait image?
Regards
Lee Francis