Adding a class to an image in MicroTiny and CMSMS 2.1.1

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
Stom
Forum Members
Forum Members
Posts: 82
Joined: Tue Jul 31, 2007 1:41 am

Adding a class to an image in MicroTiny and CMSMS 2.1.1

Post 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?
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Adding a class to an image in MicroTiny and CMSMS 2.1.1

Post 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...
Stom
Forum Members
Forum Members
Posts: 82
Joined: Tue Jul 31, 2007 1:41 am

Re: Adding a class to an image in MicroTiny and CMSMS 2.1.1

Post 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)
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Adding a class to an image in MicroTiny and CMSMS 2.1.1

Post by Dr.CSS »

The Album site is still working for me...
scotch33
Dev Team Member
Dev Team Member
Posts: 284
Joined: Tue Feb 14, 2006 9:56 pm

Re: Adding a class to an image in MicroTiny and CMSMS 2.1.1

Post 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.
Post Reply

Return to “CMSMS Core”