Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 939 posts 2574 karma points
    Jun 19, 2014 @ 12:54
    Claushingebjerg
    0

    Simple rendering of slimsy image

    Im really bad at razor, so bear with me.

    Im just trying to render a simple image using the slimsy package

    my imageattribute on the doc type is "imageID"

    @if (imageID.HasValue("Image"))
                {
                    var featureImage = Umbraco.Media(imageID.Image);
                    <img src="@featureImage.GetResponsiveImageUrl(270, 161)" alt="" />
                }

    But i get the following error:

    Compiler Error Message: CS0103: The name 'imageID' does not exist in the current context

    on the first line of the above...

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jun 19, 2014 @ 13:21
    Jeavon Leopold
    101

    Hi Claus,

    From what you've said, I think you need:

    @if (CurrentPage.HasValue("imageID"))
    {
      var featureImage = Umbraco.Media(CurrentPage.imageID);
      <img src="@featureImage.GetResponsiveImageUrl(270, 161)" alt="" />
    }
    

    Jeavon

  • Claushingebjerg 939 posts 2574 karma points
    Jun 19, 2014 @ 13:26
    Claushingebjerg
    0

    EXACTLY, thanks :)

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jun 19, 2014 @ 13:33
    Jeavon Leopold
    0

    Perfect, think I'll add a simpler example this this to the project page :-)

Please Sign in or register to post replies

Write your reply to:

Draft