Copied to clipboard

Flag this post as spam?

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


  • Natasha 79 posts 195 karma points
    Apr 27, 2016 @ 13:57
    Natasha
    0

    Link text Image Item property

    Hi All

    I'm trying to get a property from an image but keep getting the error that the property cannot be null. The code below workes but I want to add an imageItem property called caption, which is just a text field. so that the user can change the link text I've tried @imageItem.GetPropertyValue("caption") but still get the same error. Can anyone help.

    Thanks in advance Natasha

    <div class="carousel-caption">
                    @if(@imageItem.GetPropertyValue("text")!=null){
                      <p style="padding:10px 10px; background-color:rgba(73,68,68,.5);display:block; height:auto;max-width:550px;">
                          @imageItem.GetPropertyValue("text")<br/><br/>
                            @if(@imageItem.GetPropertyValue("linkPicker")!=null){
    
                                <!-- now convert to a Json object-->
                                string jsonStr = @imageItem.GetPropertyValue("linkPicker").ToString();
                                var jsonObj = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(jsonStr);
                                  var link = Umbraco.TypedContent(Convert.ToInt16(@jsonObj["id"].ToString()));
    
                                  <a href="@link.Url" style="color:#fff; font-weight:bold;">
    
                            Click here to find out more
    
    
    
                                    </a>
    
    
                            }
    
                          </p>
    
                    }
    
    
        </div>
    
  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Apr 27, 2016 @ 14:10
    Alex Skrypnyk
    0

    Hi Natasha,

    What is imageItem? Is it node in Umbraco? Can you show your Umbraco node ? Can you make some republish all you site?

    Thanks

  • Natasha 79 posts 195 karma points
    Apr 29, 2016 @ 09:31
    Natasha
    0

    Hi Alex,

    imageItem is a media node(umbracoFile). I will try republishing the whole site and see what happens.

    Best wishes Natasha

  • Natasha 79 posts 195 karma points
    May 06, 2016 @ 11:25
    Natasha
    0

    For anyone who has the same issue saving the media items again did the trick and I used

    @imageItem.GetPropertyValue("caption")
    

    Best wishes Natasha

Please Sign in or register to post replies

Write your reply to:

Draft