Hi,

I'm using this module with fckeditor & IMCE to post inline images (with optional captions).

This combination allows images to only have alt tags, not titles so the captioning fails showing 'undefined'.

I have altered the module to create a preference in the settings page that allows the (admin) user to select the tag to process into captions, so you can select 'Title' or 'Alt'.

I also duplicated the image_caption.js, renaming it image_caption_alt.js and altered the caption text variable to var captiontext = $(this).attr('alt');

I added a switch statement to the module to add either the default JS file or to use the new_alt.js file.

This seems to work fine for me, and increases the usefulness of the module:)

I'm posting the relevant files in full since I'm pressed for time at the moment.

One problem remains though, if an image is set assigned the caption class, but the title (or alt in my case) is empty the caption is listed as 'undefined' can this be removed instead?

Sorry my JS skills are non-existent :-(

Drew

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

panji’s picture

Nice,.. I like it,... cause am prefer to use alt,... fckeditor using alt,... We can paste this to the D6 version as well,..

Thx bro...

aries’s picture

+1
Simple but useful hack.

cr0546’s picture

Version: 5.x-2.1 » 6.x-2.2
FileSize
621 bytes

First thanks drew reece and davidwhthomas, you guys really helped me.

I have hacked image_caption.js too allow other classes to be included on the processing, and to allow use of both ALT and TITLE attributes to be used as caption (like ALT br TITLE if both exists, ALT or TITLE if one is blank).

This hack comes from a need of mine to include captions on images uploaded through imagefield module, which has no caption feature till now.

Thanks.

jaydub’s picture

FileSize
29.98 KB

As far as I know FCKEditor can add image TITLE tags. The attached screenshot shows where you can add the TITLE. In the 'Advanced' tab of the image dialog, the field 'Advisory Title' is the TITLE attribute. A pretty terrible label for it I know :)

Steve Dondley’s picture

I have hacked my fckeditor to put the "Advisory Title" field into the first tab. I've also change it to say "Image Caption". If you want details, let me know. I'll post them here.

milos1234’s picture

Yes please, although I cant even get the image captions to show up with this method.
Are there any changes needed from the default FCK/IMCE combo to display?
Thanks!

geerlingguy’s picture

I would like to use alt instead as well; typically I put a short descriptive title in the 'title' field, but a caption-like statement in the alt field.

I changed my copy of the module to use alt instead of title, but it would be best if there were an option in the admin interface that allows people to select either "alt" or "title."

Vacilando’s picture

Very interested in this as well (for Drupal 7). On a site I built there is an awful lot of images with this embarrassing caption: "undefined" now.