Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Steve 472 posts 1216 karma points
    Aug 26, 2015 @ 19:55
    Steve
    0

    Get Image from Mediapicker

    I am having trouble pulling in an image with the property of "featuredImage" from the docType of "NewsArticle". What am I doing wrong?

    @{
    var articles = Model.AncestorOrSelf("NewsHome").Descendants("NewsCategory").Children.Where("NodeTypeAlias == \"DateFolder\"");
    }
    @{
    <ul class="featured-listings">
        @foreach (var item in articles.OrderBy("CreateDate descending").Skip((page - 1) * pageSize).Take(pageSize))
        {
            var newsCategory = @item.AncestorOrSelf("NewsCategory");
    
            <li class="listing">
    
                <p class="tag">@newsCategory.Name - @item.CreateDate.ToShortDateString()</p>
                    @if( @item.HasValue("featuredImage")){
                        var featuredImageThumb = @Model.Media("featuredImage");
                    <img src="/[email protected]&width=154" />
                    }
                    <h3><a href="@item.Url">@item.headline</a></h3></li>
                    <p class="teaser">@item.teaser</p>
        }
    </ul>
    }
    
  • MrFlo 159 posts 403 karma points
    Aug 28, 2015 @ 07:44
    MrFlo
    0

    Hi Steve,

    You should use it like this in your loop:

    var featuredImageThumb = Umbraco.Media("featuredImage");
    <img src="/[email protected]&width=154" />
    

    I would use the ImageCropper if you need to create a thumbnail it's awesome.

  • Steve 472 posts 1216 karma points
    Aug 28, 2015 @ 13:50
    Steve
    100

    I got it working with @item.Media("featuredImage")';

Please Sign in or register to post replies

Write your reply to:

Draft