Copied to clipboard

Flag this post as spam?

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


  • Michael 63 posts 211 karma points
    Oct 06, 2014 @ 12:06
    Michael
    0

    Get image on currentpage from media picker

    Hi guys

    I working on a new umbraco and need to get an image from a media picker. I have done this before without any problems. But now the macro renders nothing. It's the same Umbraco version in both installs.

    The code from the working one looks like this:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @{     
      if (CurrentPage.HasValue("newsImg")){                                        
        var image = Umbraco.Media(CurrentPage.newsImg);
        <img src="@image.GetCropUrl("umbracoFile", "NyhedsBillede")" alt="@image.Name" />
      }
    }

    The one thats renders nothing and gives no errors looks like this:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @{     
      if (CurrentPage.HasValue("billede")){                                 
        var image = Umbraco.Media(CurrentPage.billede);
        <img src="@image.GetCropUrl("umbracoFile", "KolonneBillede")" alt="@image.Name" />
      }
    }

    When I try to render a text field from from the page nothing renders either. I use this:

    @Umbraco.Field("billede1Tekst")

    Both macros are inserted in my template. When I add some lorem ipsum text to the non-working one it renders fine. All my aliases are correct and so on.

    Any ideas why the image or text fields are not rendering?

     

    /Michael

  • Michael 63 posts 211 karma points
    Oct 06, 2014 @ 12:26
    Michael
    100

    Hi again guys

    I figured out what was causing the mystery. I changed doctype on the page that had to render the content. Mabye a cache somewhere I needed to clear?

    Fix = I deleted the old one a made a new one as the right doctype.

    Sorry for being a little quick on the trigger :)

     

Please Sign in or register to post replies

Write your reply to:

Draft