Copied to clipboard

Flag this post as spam?

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


  • Hans Jacob Thomsen 1 post 71 karma points
    Oct 21, 2015 @ 09:17
    Hans Jacob Thomsen
    0

    Set default class on img in GridLayout

    Is it possible to set default class on an ?

    I have tried configuring at custom style on the GridLayout, but it puts a

    tag around the , which doesn't make the image responsive.

    Also I would like to have a default class on all divs in the grid layout, is that possible?

  • Marc Goodson 2149 posts 14377 karma points MVP 9x c-trib
    Oct 23, 2015 @ 00:07
    Marc Goodson
    0

    Hi Hans

    There is an open issue for adding default class names to the div's in the grid layout:

    http://issues.umbraco.org/issue/U4-6585

    and a potential fix here: https://github.com/umbraco/Umbraco-CMS/pull/678

    that I've been using recently on sites with a grid layout.

    I'm not sure about setting a default class on an img, other than updating the framework rendering file in /views/partials/grids/boostrapetc.cshtml

    or potentially customize the /views/partials/grid/editors/media.cshtml file that writes out the html for a media item:

    @model dynamic
    @using Umbraco.Web.Templates
    
    @if (Model.value != null)
    {   
        var url = Model.value.image;
        if(Model.editor.config != null && Model.editor.config.size != null){
            url += "?width=" + Model.editor.config.size.width;
            url += "&height=" + Model.editor.config.size.height;
    
            if(Model.value.focalPoint != null){
                url += "&center=" + Model.value.focalPoint.top +"," + Model.value.focalPoint.left;
                url += "&mode=crop";
            }
        }
    
        <img src="@url" alt="@Model.value.caption" class="my-default-super-responsive-grid-css-class">
    
        if (Model.value.caption != null)
        {
            <p class="caption">@Model.value.caption</p>
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft