Saif Obeidat
Saif Obeidat

Reputation: 148

How to get an image URL of Umbraco members

I have some members in my Umbraco website , and i want to display some details of the members such as : Member Brief, Member Webiste , Member picture .

So the issue that i have is wow to get the member image URL (which surrounded by the red circle in the below image ) ?

enter image description here

The problem I have is How to get the member image ?

I tried to use the main method to display an image from Umbraco , which I use always to display images ,

@{
var memberImage= memberItem.GetPropertyValue<IPublishedContent>("memberImage");
if (memberImage!= null)
{
    <p>@memberImage.Url</p>
    <img src="@memberImage.Url" />
}

}

but it didn't work , and i got this error

'IMember' doesn't contain a definition for 'GetPropertyValue' and the best extension method overload 'PublishedContentExtensions.GetPropertyValue(PublishedContent,string)'

I changed GetPropertyValue to GetValue , i get null value .

Any one have an idea of how to display member image on the website ?

Upvotes: 0

Views: 966

Answers (2)

Saif Obeidat
Saif Obeidat

Reputation: 148

The solution for my question is :

1- Use File Upload property instead of Media picker .

2- Use the below code to retrieve the image URL :

    var memberImage = memberItem.GetValue<string>("memberImage");
     <img src="@(memberImage != null ? memberImage : "")" />

Upvotes: 1

Jannik Anker
Jannik Anker

Reputation: 3425

Try a "simple" .GetPropertyValue("yourPropertyName") instead, maybe? I don't think you will get IPublishedContent from a member property - most likely the property will be an Image ID/UDI or the image URL.

Upvotes: 1

Related Questions