Is it possible to add a button to the rich text editor that would allow users to add padding to an image? I guess one option would be to set up a style sheet for it but I was wondering if there may be a better/earier way.
Thanks!
I doubt it. You might do better to use the grid editor. Then you can either have a 'Padded image' grid editor item or you can add a CSS class to the row that contains the image.
I have yet to find a great solution to this that also gives editors control over how much padding to give an image. Instead, I've opted for an absolute approach that adds margin to all images with a left or right alignment. This is done in two stages, one targeting the RTE itself in the backoffice and the other targets the content rendered on the front-end.
Then on the front-end, we have something similar albeit with a different parent selector, as body.mce-content-body is exclusive to the backoffice. The trick here is that you need to wrap the rendered content (from the RTE) in some predefined class. In the example below, I edit the /Views/Partials/Grid/Editors/Rte.cshtml partial to add a custom wrapper:
Again, this applies margin to ALL images in an RTE with left or right alignment and does not allow for editor adjustment. One would think that this would be trivial by allowing editors to assign a class (or format) to an image, but I have yet to be able to do that gracefully with the latest version of Umbraco.
Add padding to rich text editor?
Is it possible to add a button to the rich text editor that would allow users to add padding to an image? I guess one option would be to set up a style sheet for it but I was wondering if there may be a better/earier way. Thanks!
I doubt it. You might do better to use the grid editor. Then you can either have a 'Padded image' grid editor item or you can add a CSS class to the row that contains the image.
You could also apply a CSS class the image by adding an style to the stylesheet, but your editor might find this unintuitive. http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/stylesheets-and-javascript/setting-up-rte-styles/documentation
My issue with using the grid editor for floating images beside content is that the text doesn't wrap, leading to unwanted white space.
David, Thanks for the info. I'll check that out. Steve
I have yet to find a great solution to this that also gives editors control over how much padding to give an image. Instead, I've opted for an absolute approach that adds margin to all images with a left or right alignment. This is done in two stages, one targeting the RTE itself in the backoffice and the other targets the content rendered on the front-end.
Here's my stylesheet for the backoffice RTE:
Then on the front-end, we have something similar albeit with a different parent selector, as
body.mce-content-body
is exclusive to the backoffice. The trick here is that you need to wrap the rendered content (from the RTE) in some predefined class. In the example below, I edit the /Views/Partials/Grid/Editors/Rte.cshtml partial to add a custom wrapper:Then I add the following rules to my front-end css:
Again, this applies margin to ALL images in an RTE with left or right alignment and does not allow for editor adjustment. One would think that this would be trivial by allowing editors to assign a class (or format) to an image, but I have yet to be able to do that gracefully with the latest version of Umbraco.
Thanks Matt!
is working on a reply...