For thumbnails of graphics or pictures, it's common to set the caption to be empty so just the image shows. However, this means that those without images don't get proper alt or title attributes. This can be easily dealt with by overriding theme_img_assist_inline(), but I think it should be set like this in the default theme implementation. Here is what I have in my template.php:

$title = strip_tags($caption);
if (!empty($title)) {
  $node->title = $title; // change the node title because img_assist_display() uses the node title for alt and title
}

If this is considered something to be included, what should I roll a patch against? HEAD, or each individual -dev branch? Thanks!

--Andrew

Comments

sun’s picture

I would accept a patch that sets the ALT attribute to an empty value (if this is not already the case), because outputting the node's title if a user explicitly did not define a title or description would be a false assumption in most cases. I have users who name their image nodes "abcabc", just because the node title is required - such titles should not be output in any case.

All patches need to be done against latest code in CVS and against the corresponding branch (in this case, that'd be DRUPAL-5)

sgriffin’s picture

This is a very good idea, it also allows a modal box to show the caption. Otherwise, you MUST insert as HTML to remove the shown caption.
Perhaps two tick boxes could be there for outputing the span caption and alt= and title=

sun’s picture

@sgriffin: I'm sorry, I did not understand what you were trying to say (besides the checkboxes).

antgel’s picture

Subscribe

sun’s picture

Status: Active » Postponed (maintainer needs more info)

Could someone please take the time to clearly summarize what the intention of this issue is? Meaning: What is IA currently doing (in certain cases), and what should it do?

sgriffin’s picture

OK, when you insert an image with image assist, without a caption/title, it does not include the images title/caption in the alt and title tags.
The reason you would want to insert an image without the title/caption is so that it does NOT include the <span> information.
If you keep an organized image collection with accurate node titles, you always want this information included in alt and title. Even if you do not, I do not see the harm of including an alt= and title= for your junk node titles.
I have personally, edited image assist, so that it does just this.

It would be great, if there was a tick box, to include or not either the caption span, or alt and title. Either way.
Like
[checkbox] Include Caption
or include a new field derived from the title called caption
Then you would have to update the filter tag, to add a caption= instead of reusing the title for both.

sun’s picture

Title: Insert alt and title attributes even when the caption is empty » Optional image caption
Version: 5.x-1.x-dev » 5.x-2.x-dev
Status: Postponed (maintainer needs more info) » Active

btw: 2.x supports Token module for generating the contents of the title and description fields in IA's popup property window.

The original issue title "Insert alt and title attributes even when the caption is empty" was a won't fix (because of the reasons outlined in #1), so thank you for clarifying.

Always inserting title and alt attributes won't fix, too (for the very same reasons). But introducing a new checkbox to optionally output the title and description fields as image caption (below the image), sounds sane.

However, I don't know whether I'll have time to implement this - IA 2.x as well as improving Inline API have much higher priority on my list currently. Of course, I'd be happy to review and test a patch ;)

deviantintegral’s picture

@sun: I know it's bad form, but I'm going to blame the users (my users too!). I can understand why someone might put junk into the node title field, but not being able to rely on $node->title opens a whole can of worms for contributed modules (since title field is required without hacking the form). If users are putting invalid information into the title field, then they should be 'reeducated' to put something valid in. If a user were to put junk in a Story title, it's still fair game for output :).

In my specific case, we need accurate titles of images for accessibility, to ensure that screen readers have something to work with. We don't need the caption to be rendered in the span tags, as users who can see images can figure it out by looking at the image. Since by default the title field is required, and can't be disabled through core itself, how about an enabled-by-default option to fill in the alt tags, but able to be disabled on a site-by-site basis?

--Andrew

sun’s picture

@Andrew: There are perfectly valid ways to auto-generate node titles, for example http://drupal.org/project/auto_nodetitle. Until now, the purpose of Image Assist is to allow end-users to have total control over inline images, and I do not see a reason why we should start to limit possibilities now. Wouldn't a checkbox to enable/disable the image caption (but always outputting the HTML attributes) be sufficient for your use-case, too?

sgriffin’s picture

Yes, sun you have the right idea. That would be great.

deviantintegral’s picture

Yes sun, I think your solution will be fine.

Thanks,
--Andrew

sun’s picture

Great. However, this will be the first change in the inline filter tag since years, so we need to be sure to change it in all the required places, and also test that everything works properly in all possible ways. If someone wants to start with a patch, I would be happy to review and assist.

mgifford’s picture

Issue tags: +Accessibility

Having more accurate user controls/encouragement over alt tag usage is important. Not a lot of good examples of a best practice that can either gently encourage or actively enforce meaningful alt tags by users when images are uploaded.

Auto fail-overs are generally useless.

Mike