1
  @{
    var partnerReviews = CurrentPage.Site().FirstChild("generalDataType").Children("partnersReview").Where("Visible");
}

    @foreach(var item in partnerReviews){
        <div class="col-lg-4">
        <div class="bubble">
                    @item.partnerReviewMessage
                </div>
                <div class="comments-avatar">
                    <a href="" class="pull-left">
                        <img alt="image" src="./img/avatar3.jpg">
                        <img src="@Umbraco.TypedMedia(Convert.ToInt32("@item.partnerImage").ToString()).Url" />    
                    </a>
                    <div class="media-body">
                        <div class="commens-name">
                            @item.partnerName   
                        </div>
                        <small class="text-muted">@item.partnerCompanyName</small>
                    </div>
                </div>  
         </div>
    }

I have created a partial page to render all the review message created by a user under partner review. Each message contains review message, partner name, partner company name and image of partner.I have used media picker to upload or select an image.

I have created above loop to render all the message on my page. All the things except image rendering perfectly. Can anybody help me in getting the URL of images from media library?. @Umbraco.TypedMedia(Convert.ToInt32("@item.partnerImage").ToString()).Url

What's the problem with this line I'm not getting.It is working correctly in a template and not with a partial page. What may be the reason?

Parth Patel
  • 3,937
  • 2
  • 27
  • 44

1 Answers1

1

I think this should work?

<img src="@Umbraco.TypedMedia((int)item.partnerImage).Url" />

Take a look here: https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/

Jannik Anker
  • 3,320
  • 1
  • 13
  • 21
  • Thanks @Jannik Anker, I have solved the problem.The solution you have suggested is not totally correct.We just need to replace TypedMedia to Media.Bingo!! it works. – Parth Patel Mar 18 '16 at 04:34
  • 2
    `TypedMedia` IMO is usually the better option to `Media`. If your code works with `Media` and not `TypedMedia` it usually points to some underlying problem with the way you're using the api – glcheetham Mar 20 '16 at 13:49