Allow caption to use alt field instead of title

drew reece - September 3, 2008 - 04:06
Project:Image Caption
Version:6.x-2.2
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

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

AttachmentSize
alt_tag_captioning_mod.zip2.16 KB

#1

panji - October 14, 2008 - 05:11

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

#2

aries - October 19, 2008 - 19:24

+1
Simple but useful hack.

#3

cr0546 - November 13, 2008 - 19:45
Version:5.x-2.1» 6.x-2.2

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.

AttachmentSize
image_caption_alt.zip 621 bytes

#4

jaydub - November 14, 2008 - 06:28

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 :)

AttachmentSize
fckeditor-image-title.jpg 29.98 KB

#5

Steve Dondley - January 11, 2009 - 21:05

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.

#6

milos1234 - February 18, 2009 - 15:01

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!

#7

geerlingguy - May 18, 2009 - 17:21

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."

 
 

Drupal is a registered trademark of Dries Buytaert.