Joomla Images with Caption and Extra Style
Problem statement: I have inserted an image using the TinyMCE editor in a Joomla 1.5 article. How do I get the image to display both a caption and a border? I do not want borders on all images but only those I specify.
At first glance, the solution seems as though it would be simple and straightforward but it actually requires some tricks. This article will approach the issue in a somewhat backward approach; starting with what is required of the end-user editor, then going to changes required of the administrator, and finally touching on a little of the why.
For the Editor
Simple steps:
- Create your article and insert your images using the standard methods.
- Add a caption
- Click on the image so that it is highlighted
- Click on the ‘Insert/Edit Image’ icon
- In the ‘General’ tab, enter a Title (the title is used to become the caption)
- In the ‘Appearance’ tab, set the class to caption
- Add a border
- Click on the image so that it is highlighted
- Click on the ‘Insert/Edit Attributes’ icon
- In the ‘Attributes’ tab, set the class to (value)
- Enter border as the class (this is border only, no caption)
- Or, enter caption border as the class (the image will have a border and a caption)
- Save all of your changes
Where is the ‘Insert/Edit Attributes’ icon? Well, if your administrator has set up everything correctly, it should appear as in the image below.
For the Administrator
In the default installation of Joomla, the ‘Insert/Edit Attributes’ icon does not appear in the TinyMCE toolbar. Additionally, the border style is not part of the default CSS. Both of these are easily fixed.
TinyMCE Plugin
The settings for the TinyMCE editor are available from its plugin. The steps are:
- Click ‘Editor – TinyMCE’ from the Extensions > Plugins Manager.
- Make certain that ‘Functionality is set to Advanced in the Plugin Parameters
- Select Show for XHTMLxtras in the Advanced Plugin Parameters
- Save changes and the icon will appear in the TinyMCE toolbar
CSS for Caption and Border
The CSS for captions are initially set in a system CSS file. These settings may be overridden in your stylesheet. Below is my caption CSS.
/* Caption overrdies */
.img_caption.left {
float: left;
margin-right: 1em;
}
.img_caption.right {
float: right;
margin-left: 1em;
}
.img_caption.left p {
clear: left;
text-align: center;
color: #666;
}
.img_caption.right p {
clear: right;
text-align: center;
color: #666;
}
l also add a short style to set the border around an image.
img.border { border: 1px solid #000; }
Why?
Joomla has taken an interesting and resonable approach for adding captions to images. Joomla simply takes the image’s title, processes it with some javascript, and outputs it with the image. The final display of the caption is controlled by the CSS. The files used are:
- /templates/system/css/general.css
- /media/system/js/caption.js








June 1st, 2009 at 6:53 am
Thanks for the article – this works on Firefox and Chrome, but not on IE6 or IE7. Any ideas? Thanks
June 1st, 2009 at 12:05 pm
@John Crumpton
Hmm. the client using this solution was using IE6 and is now upgrading to IE7. Where are you having the problem, creating the extra styles or viewing the styles?
August 11th, 2009 at 6:48 pm
The core css captioning system is very poor but we rewrote the code and have now updated and included some nice new features including quotation captions and independent text captions.
Feel free to take a look: http://www.simplytoday.com/categoryblog/joomla-updated-and-working-css-image-captions-and-text-captions.html
Hope that helps this thread.
Julie Gibbins – CEO
SimplyToday.com
January 11th, 2010 at 2:15 pm
Thank you, but I think there’s is missing this javascript for the administrator side.
February 4th, 2010 at 2:32 pm
@Jaime
Sorry, but I don’t think I understand your question. We are not touching any of the core javascript but instead working with the story editor and the CSS.