Jump to:

513 Posts in 209 Topics by 259 members

Content Editor Discussions

SilverStripe Forums » Content Editor Discussions » How to apply CSS class to inserted image?

Forum for content editors and CMS users.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 31526 Views
  • dewoob
    Avatar
    Community Member
    10 Posts

    How to apply CSS class to inserted image? Link to this post

    Hi,

    I'm still using SS 2.2.2. When I insert an image into an HTMLText field, the resulting HTML does not contain any CSS class information. When I try to align the image, no class attribute is added, either. All the editor does is generate align, hspace and vspace attributes. Apart from the fact that those have been deprecated for decades, they don't even work. I have reset margins and paddings globally using something like

    * {
    margin:0;
    padding: 0;
    }

    These CSS settings seem to override hspace and vspace.

    I've found some "img.left" and "img.right" class definitions in typography.css, so it seems like CSS support for editor-added images is built-in - but those classes are just not used.

    Are those classes supposed to be used automatically?
    If so, why is it not working? If not, how can I do it manually without editing the source code?

    Thank you in advance.

  • grilldan
    Avatar
    Community Member
    135 Posts

    Re: How to apply CSS class to inserted image? Link to this post

    I don't think you can do it without editing the source code. It's not hard to edit the source code, just find the "img" tag and add a 'class="class_name" ' to it.

    start : <img src="assets/uploads/me.jpg" />
    finish: <img src="assets/uploads/me.jpg" class="me" />

  • dewoob
    Avatar
    Community Member
    10 Posts

    Re: How to apply CSS class to inserted image? Link to this post

    Thank you for your answer. I know how to do it manually - I just thought I could either install a new version of the editor or make some config settings in order to change the editor's behaviour. I would want it to use CSS instead of deprecated HTML attributes for the aligning and positioning of images. I don't need a rich-text editor to hack HTML code...

    31526 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.