Search code examples
c#sitecoreglass-mapper

Glass mapper Render Image data attributes


I'm trying to render a image field with RenderImage. I need some data- attributes in the image but I can't seem to figure out how to go about implementing that. I've tried this but doesn't work

@RenderImage(image, x => x.Image, new RenderingParameters("data-protect=true"), isEditable: true)   

Thanks


Solution

  • Try it like this:

    @RenderImage(image, x => x.Image, new ImageParameters { Width = 100}, isEditable: true)
    

    As of recent version of Glass - the only possible solution is

    @RenderImage(image, x => x.Image, new { Width = 100}, isEditable: true)
    

    Also you can take a look at - TUTORIAL 16 - RENDERING IMAGES