Copied to clipboard

Flag this post as spam?

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


  • hrcodenstuff 6 posts 128 karma points
    Oct 17, 2016 @ 17:19
    hrcodenstuff
    0

    Add CSS Class attribute to Standard Image Editor

    I am new to Umbraco, and just discovered that the Image editor (the one that is included in selectable editors for content rows) does not provide a way to enter a CSS class. This is surprising, considering that it is pretty standard these days to use Bootstrap classes to style images (img-responsive, for example). Example screen shots are below.

    While I understand that I can set a class within the Umbraco UI on the containing column div, this is not ideal. I also understand that I could use the Rich Text Editor, but this seems to be overkill for a column that is intended to contain images only.

    What I would like to do is modify the existing editor to allow users to enter CSS classes, but I cannot find it.

    Has anyone made this modification to your own implementation of Umbraco, and if so, could you guide me to how I could do this?

    EXAMPLE:

    Select the column:

    enter image description here

    Select the Image editor:

    enter image description here

    Click to insert image:

    enter image description here

    Note that the only fields available are UrL and Alternate Text. Would like to modify so that user can add a CSS class (or classes) here.

    enter image description here

  • Sven Geusens 169 posts 881 karma points c-trib
    Oct 18, 2016 @ 12:25
    Sven Geusens
    0

    Hey and welcome to Umbraco

    After reading trough your post and seeing all the images, it is clear you are using the Grid.

    As far as I can see you have figured out how to setup the Grids basic configuration (rows/columns) and the question is how can I extend grid editors.

    There are a few ways to do this but you have to understand the following: a grid editor has a 2 important parts: (1) The underlying data and the way it is retrieved (angular controllers and whatnot) (2) the renderer.

    If you just want to change the way something is rendered. You can go into the backoffice (developer-grid editors) and create a new grid editor based on one of the existing types. Based on which type you choose, you can edit some things straight into the backoffice.

    For example, the following grid editor will simple be rendered as a H2 (no razor/js/no nothing required) enter image description here

    For the more advanced data types (like image) you will have to provide a custom renderer. Just create the grid editor like the previous one and then fill in the render field. To actually make the renderer, you will need to use some razor script. Go into /Views/Partials/Grid/Editors and copy the cshtml file corresponding to the type of grid editor you are making a new renderer for (image uses media), edit the html like you see fit and save it with the same name as you put into the render field in the backoffice.

    If you want to use a custom data type (image + radio list of css classes + caption + whatever) then have a look at leblender. OR write your own grid editor or don't because its madness and 9/10 leblender will suffice

    I hope this covers your question and then some.

    Sven

Please Sign in or register to post replies

Write your reply to:

Draft