Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 886 posts 2415 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 3008 posts 13221 karma points MVP 7x 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 886 posts 2415 karma points
    Jun 19, 2014 @ 13:26
    Claushingebjerg
    0

    EXACTLY, thanks :)

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x 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 :-)

  • 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