Search Results for

    Show / Hide Table of Contents

    Image Renderer

    The ImageRenderer will render an image tag to display a media item.

    var media = client.Load<Image>(353)
        .Single();
    var context = new RenderContext(media);
    
    //You can of course force the image renderer if you would like to
    //context.RendererId = ImageRenderer.RendererId;
    
    var html = MediaRenderer.Render(context);
    

    The following context values can be used to control the behavior of the image tag. (In addition to the generic context keys that can be set to all renderers.)

    Url

    Translated to the src attribute of the img element.

    Default is the url to the media item

    context.Set(ContextKey.Url, "https://my.imagevault.app/publishedmedia/TestImage/img.png");
    

    Alt

    Translated to the alt attribute of the img element.

    Default is not set

    context.Set(ContextKey.Alt, "Logotype with text ImageVault");
    

    Width

    Will be translated to the width attribute of the img HTML element.

    Default is set to the width of the image

    context.Set(ContextKey.Width, 116);
    

    Height

    Will be translated to the height attribute of the img HTML element.

    Default is set to the height of the image

    context.Set(ContextKey.Height, 41);
    
    In This Article
    Back to top (c) Meriworks 2002-2022