Copied to clipboard

Flag this post as spam?

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


  • Jim 18 posts 36 karma points
    Nov 24, 2010 @ 15:04
    Jim
    0

    Media Items Test For No Image

    Hi, I have searched these forums but can't find what I am looking for.

    Using umbraco v 4.5.2 (Assembly version: 1.0.3891.20719):

    I am trying to test for an image field being empty.

    <%if(umbraco.library.GetItem("bannerImage") != "") {%>
                <div class="banner">

                  <umbraco:Item runat="server" field="bannerImage" xslt="concat('&lt;img src=&quot;',umbraco.library:GetMedia({0}, true())/umbracoFile, '&quot; /&gt;')" xsltDisableEscaping="true"/>
     
                </div>
            <%}%>

     

    This is from a user control.

    How do I achieve what I am trying, I have looked at GetMedia but this returns an xml node iterator

     

    Can someone help?

  • Jim 18 posts 36 karma points
    Nov 24, 2010 @ 16:27
    Jim
    0

    I ended up going round in circles until I found a snippet pointing at the extensions available in umbraco:

     

            <%if (umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("bannerImage").Value != "")
              {%>
                <div class="banner">

                  <umbraco:Item runat="server" field="bannerImage" xslt="concat('&lt;img src=&quot;',umbraco.library:GetMedia({0}, true())/umbracoFile, '&quot; /&gt;')" xsltDisableEscaping="true"/>
     
                </div>
            <%}%>
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies