Copied to clipboard

Flag this post as spam?

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


  • Jeremy Wiersma 37 posts 134 karma points
    Mar 12, 2015 @ 11:08
    Jeremy Wiersma
    0

    Cannot get image URLs iterating through child nodes

    Well my old nemesis is back to kick my butt eh Jeavon ;)

    I have 3 Testimonial items that are children under my Testimonials page.

    As I did on a previous but earlier 7.x version of Umbraco I attempted to display these items on my Testimonials page using this code;

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = "tmpAbout.cshtml";

        var homePage = Model.Content.AncestorOrSelf(1);
        var testimonials = homePage.Children.OfTypes("dtTestimonials").First();
        var testimonialItems = testimonials.Children.OfTypes("dtTestimonial");
    }

    <h1>@Umbraco.Field("propPageTitle")</h1>

    <ul class="testimonials">
        @{
            foreach (var testimonialItem in testimonialItems.Where("propHide = false"))
            {
                <li>
                    <div class="quote">
                        @if (testimonialItem.HasValue("propTestimonialCompanyLogo"))
                        {
                            <img class="logo" src="@testimonialItem.GetCropUrl(propertyAlias:"propTestimonialCompanyLogo")" alt="@testimonialItem.GetPropertyValue("imageAlt")" />
                        }
                        @testimonialItem.GetPropertyValue("propTestimonialCopy")
                    </div>
                    <div class="bubble-tip"></div>
                    <h5>@testimonialItem.GetPropertyValue("propTestimonialName"), @testimonialItem.GetPropertyValue("propTestimonialPosition"), @testimonialItem.GetPropertyValue("propTestimonialCompany")</h5>
                </li>
            }
        }
    </ul>

    Now what results is a nice list of Testimonials i.e. text content, minus the logos. I can get the path to the logos, the id to the logos, and the above returns this "1107?mode=pad&rnd=130704961800000000".

    I can verify that the Image Media Type contains the umbracoFile property. I am using the MediaPicker field type which is used to select an image from a media folder.

    What I have noticed is that the image in the Media folder has an ID of 1107, which matches the data being returned in my image call above (at least for one of the images of course). But when I try something like;

    @testimonialItem.GetPropertyValue("propTestimonialCompanyLogo")

    I get an ID of 1027 returned, which matches the ID of the image being displayed on this particular Testimonial in the Admin. I assume though that this is normal.

    So... what have I missed this time, any idea folks / Jeavon?

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 15, 2015 @ 10:10
    Jan Skovgaard
    0

    Hi Jeremy

    Have you tried using this instead

    <img src='@testimonialItem.GetCropUrl("umbracoFile", "Logo")' />
    

    Looking forward to hearing from you.

    /Jan

  • Jeremy Wiersma 37 posts 134 karma points
    Mar 18, 2015 @ 05:52
    Jeremy Wiersma
    0

    Thanks Jan... sadly that doesn't work either.

    I've decided to implement my solution using a media folder and tags for now... but I really want to know what's going on.

    Project deadline is tonight so once that's done I'll come back to this and figure it out :)

Please Sign in or register to post replies

Write your reply to:

Draft