Copied to clipboard

Flag this post as spam?

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


  • Martin 278 posts 662 karma points
    Nov 08, 2016 @ 14:45
    Martin
    0

    Get Image in Foreach

    Hi, Im sufre im being stupid here, but having some issues with getting an image showing my partial.

    Im using the Nested Content + Doc Type Grid Editor in 7.5

    Any ideas on how I can pull an image in?

    Thanks

    Martin

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
        @if(Model.HasValue("carousel")){
    
            var items = Model.GetPropertyValue<IEnumerable<IPublishedContent>>("carousel");
            if(items.Any()) {
    
            <div class="carousel">
    
            @foreach(var item in items) {
    
                <div class="carousel-cell">
    
                    @if(item.HasValue("image")) {
                         var image = Umbraco.TypedMedia(item.GetPropertyValue("image"));
                        <img src="@image.Url">
                    }       
                </div>                      
            }
            </div>
            }
    
        }
    
  • Martin 278 posts 662 karma points
    Nov 08, 2016 @ 15:47
    Martin
    101

    Sorry, long day. Ive got it. Im sure ive tried it before.

                @if(item.HasValue("image")) {
                var image = item.GetPropertyValue<IPublishedContent>("image");
                <img src="@image.Url"/>
                }   
    
  • Alex Skrypnyk 6131 posts 23950 karma points MVP 7x admin c-trib
    Nov 08, 2016 @ 16:12
    Alex Skrypnyk
    0

    Hi Martin,

    So did you solve you solution?

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft