Page 1 of 1
Adding a class to an image in MicroTiny and CMSMS 2.1.1
Posted: Tue Jan 26, 2016 6:37 am
by Stom
Is it possible to add a class to an image? Or a span? I don't see an option for it in the editor.
Extensions -> MicroTiny -> Settings -> Admin Editors -> Stylesheet for editor is set to a test sheet with a few sample classes in it. I want to be able to apply one of these classes to images added in the editor. This used to be possible with the only TinyMCE, is it still?
Re: Adding a class to an image in MicroTiny and CMSMS 2.1.1
Posted: Tue Jan 26, 2016 5:48 pm
by Dr.CSS
Do you have the classes set up as img.class {some styles} or just .class {somestyles}..?
You may be able to add the class when adding the image there may be a tab for advanced functions in the image picker where you browse for images to insert...
Re: Adding a class to an image in MicroTiny and CMSMS 2.1.1
Posted: Fri Jan 29, 2016 2:26 am
by Stom
Sadly there is no option to add a class, either img.class or .class, to an image using the default MicroTiny setup.
However I've since found that TinyMCE is still maintained and provides this functionality (along with much more) right out of the box, with a very similar interface. It's also has a lot more config options, so I'll stick with that for future projects.
Thanks for your help!
(Also, I *have* wondered what happened to the Album module as per your sig, but your website appears to be down currently)
Re: Adding a class to an image in MicroTiny and CMSMS 2.1.1
Posted: Fri Jan 29, 2016 5:16 pm
by Dr.CSS
The Album site is still working for me...
Re: Adding a class to an image in MicroTiny and CMSMS 2.1.1
Posted: Thu Jun 13, 2024 11:33 am
by scotch33
I found a solution to this issue using JavaScript. Here it is in case a help...
ECB add a checkbox to the template like this sorta thing:
Code: Select all
{content_module module=ECB2 field=checkbox block=floatimagesright label='Float an image in the main text to the right and wrap text around it?' default=1 assign='floatimagesright'}
2. Add something like this to the parent div of where you want image (or any specific element to get a class) (see the if statement in the bit below
Code: Select all
<div id="inner_main_content" class="inner {if $floatimagesright==true} floatimagesright{/if}">
3. add this into your javascript:
Code: Select all
$('.floatimagesright img').addClass('right_wrapper');
if it gets checked, any image within that div gets the class added. This of course assumes JavaScript is allowed by the user, It's a bit of a workaround, but it's done the thing I need.