The 'problem':

When sites did not install the token module, or when users submit an empty alt / title value, the alt / title attributes will show up as empty.

<.... alt="" title="" ....>

This is not a huge deal, but not all sites run token. So 'we', the Drupal community, would end up running a lot of sites that show empty alt / title attributes, while we are more then capable of preventing this, and thus making it better, or at lest improve it a lil bit.

So i created a new option on the view mode page for image:
'Enforce non-empty attributes'
This enables the use of the file title in the case the token module is not installed - OR - if the submitted fields are empty. (edit node > clear alt+title > save node > view node).

This patch also makes core and file entity deal in the same way with empty title attributes, it just doesn't render them. An empty alt attribute will always render - as it should.

To be honest, i think this doesn't even require an option. If we document this behaviour enough, it should be fine - and be the default.

But as promised:

#1885732: Documenting alt and title tags on image fields
#1553094: Alt and Title support for Images

Possible TODO:
- Maybe use the node title if we are rendering on a node as the title attribute in combination with the file name?

(interesting to see what search engines will do with photo albums, including the albums with filenames with only numbers, or node/file title . album picture display id.)

file_entity_enforce_non_empty_attributes_plus_fix_empty_title_consistency.patch3.88 KBRob C
PASSED: [[SimpleTest]]: [MySQL] 308 pass(es). View


ParisLiakos’s picture

Status: Active » Needs review

lets check with testbot anyway

slashrsm’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Looks OK, but it would be nice to have tests for this...

castawaybcn’s picture

I tried applying this patch to the latest dev and got the following errors:

patching file file_entity.module
Hunk #1 FAILED at 607.
Hunk #2 succeeded at 1210 with fuzz 2 (offset 482 lines).
Hunk #3 FAILED at 757.
Hunk #4 FAILED at 767.
Hunk #5 succeeded at 1303 (offset 482 lines).
3 out of 5 hunks FAILED -- saving rejects to file file_entity.module.rej

Perhaps I am doing something wrong?

Rob C’s picture

Naah castawaybcn, the patch can use a reroll, but i'm not even sure if it's still valid. (while i do think we could make this work like advertised). Got a backlog a mile long, so if anyone wants to^^

mgifford’s picture

Issue tags: +accessibility