the themeing guide should include an explanation of how to set the logo in page.tpl.php
-----
Problem/Motivation
On the theme settings page users can add a new site logo, but cannot change the alternative text, alt attribute, for the logo image. Currently the alt attribute for all Core themes are hard coded into page.tpl.php as "Home", with the exception of Garland, which uses $site_name_and_slogan.
Proposed resolution
Provide a 'logo_alt_text' setting on the theme settings form, and modify Core themes to provide a default for this setting in their .info file.
Remaining tasks
Modify patch in #14
1.Make sure that Logo alternative text #textfield is available even when using default theme logo.
2. Remove default for 'logo_alt_text' from theme_get_settings()
3. Update Core theme .info files to provide setting[logo_alt_text] = default alt text
User interface changes
A new Logo alternative text textfield will be added to the logo section of the theme settings form.
API changes
1. The alt attribute for theme logos should no longer be hard coded into page.tpl.php, but should be printed from $logo_alt_text.
2. Themes should define the default alt text for their logo in the theme .info file using:
settings[logo_alt_text] = Alternative text
Original report by Everett Zufelt
When administrators add a custom logo to any of the core themes they are not able to add a custom alt attribute for the image. By default the alt attribute assigned to the logo image (whether the image is the default theme logo or a custom logo) is the site name.
In order to meet the WCAG 2.0 accessibility guideline images that convey information must be marked up with an appropriate alt attribute. Not all images will require a custom alt attribute, but some will, and the ability to provide this currently does not exist for core themes.
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | logo-custom-alt-717708-31.patch | 8.33 KB | andrewmacpherson |
| #28 | logo-custom-alt-717708-28.patch | 8.31 KB | andrewmacpherson |
| #18 | logo_attributes.tar_.gz | 23.41 KB | andrewmacpherson |
| #14 | logo-custom-alt_1.patch | 5.39 KB | Everett Zufelt |
| #5 | screen-capture-5.png | 49.02 KB | mgifford |
Comments
Comment #1
johnalbinTo clarify, that's only true in Garland. Stark uses "Home" as the logo's alt text.
Comment #2
sun.core commentedComment #3
joachim commentedI think for an interim measure, we can consider this a bug to be fixed:
- all core themes should have the same alt attribute for the logo
- this should be something more descriptive such as 'logo for $sitename' or '$sitename logo'. (see #787634: Site title is read three times with VoiceOver in Garland. for more background on this)
Let's get this fixed, and then move the provision of a custom alt attribute to D8.
Comment #4
Everett Zufelt commented@joachim
Thanks for taking interest in this. But I think that you should file separate issues against the core themes which need to have their alt text modified.
Comment #5
mgiffordSo you're looking to add something like this to the system_theme_settings() function of modules/system/system.admin.inc?
I added it to line 544 and attached a screenshot for review.
Comment #6
mgiffordCan this be brought into D7 using the Accessible Helper Module?
Comment #7
Everett Zufelt commentedNot a feature request, but a bug. We provide a UI through which a logo can be applied to a site, but do not provide a UI through which an appropriate alt attribute can be set for the logo.
Comment #8
bowersox commentedThe solution in #5 looks good. Then we would make a 1-line change in Garland page.tpl.php and other themes to apply that ALT attribute.
Comment #9
anouHello,
Still not in core. Should be I think. It's good for accessibility.
Comment #10
andrewmacpherson commentedWe discussed this at the DrupalCon London Accessibility BoF - http://groups.drupal.org/node/168744/
I did some work towards this for a D6 module which I never brought to full project status. I'll dig it out as a sandbox project.
Comment #11
Everett Zufelt commented@Andrew
If you don't want to build a full project for D6 you can just write a patch against 8.x-dev and post it here. If you haven't done core patches before let us know and we can guide you through it.
Comment #12
andrewmacpherson commented@Everett
Sure. I'll try to get around to it soon. Still catching with stuff after DC and other travel.
Comment #13
mgiffordThat would be great Andrew, thanks!
Comment #14
Everett Zufelt commentedA first pass.
- Extends theme settings form to allow for custom alt text
- Provides a $logo_alt_text variable in template_preprocess_page()
- Changes all themes to use $logo_alt_text
Comment #15
Everett Zufelt commentedOnly issue that I see that needs to be resolved is that logo_alt_text in theme_get_setting() is always used for the alt text.
So, if someone adds a custom logo with custom alt text, then goes back to using the default logo provided by the theme the alt text stays custom.
Perhaps a test in template_preprocess_page() to test if logo is default.
if default use "Home" or whatever we decide for default alt text.
If custom use theme_get_setting('logo_alt_text)
This also means that contrib themes can use:
mytheme_preprocess_page()
If default logo:
$variables['logo_alt_text'] = "My super awesome theme logo"
else
$variables['logo_alt_text'] = theme_get_setting('logo_alt_text')
Thoughts?
Comment #16
Everett Zufelt commentedSelf reminder / comments.
Should make logo_alt_text #required
Comment #17
mgiffordI just took a quick look at the patch & had some questions about $site_name_and_slogan
Could this be used to populate the alt text by default when setting up the page?
It is certainly something that we have to get into D8.
Comment #18
andrewmacpherson commentedHi,
As mentioned at the London BoF, here is my earlier attempt at implementing this as a D6 module. As far as I can recall, it was in a working state. If you want to try it out, there's a modified version of Stark which included, with the necessary page.tpl.php changes. There are quite a lot of @todo comments, but hopefully you can see where I was going.
Being a module, it's a bit more verbose than the patch, with a hook_form_alter()
It's called logo_attributes, as I was considering use cases for other attributes like the logo' link @title, or even @rel=[start|contents]. (These use-cases are out of scope for this issue.)
@17: Yes, I also wondered about offering site name and slogan as options. (They are commented out in my module.) These could be relevant even if using the logo image provided by the theme. This use case was intended to cover the scenario where the logo was set to display, but the site slogan and site name were not.
Supporting tokens could be another option.
Comment #19
Everett Zufelt commentedI'd like to keep discussion of a sensible default in #1270598: Decide on appropriate alt text for default logo. The more options that we wish to offer on the theme settings form, the more cluttered the form becomes, and the less likely that the patch will get committed.
Would love to hear feedback on proposal in #15
Comment #20
Everett Zufelt commentedI talked to Jen simmons. She said that it would likely be easier for some themers to set the default alt attribute for their theme's logo in .info, and not in hook_preprocess_page(). I think she's right.
my_theme.info:
....
settings[logo_alt_text] = My cool logo
...
Edit: It appears that if we don't set a default in theme_get_settings(), which is done in the current patch, then theme_get_settings() will get the default from the info file by default.
Comment #21
Everett Zufelt commentedUpdated summary.
Comment #22
Everett Zufelt commentedThe only problems I see with using theme.info, instead of hook_preprocess_page() is:
1. You can no longer use a variable like $site_name_and_slogan for the alt text
2. Strings in theme.info are not localizable.
Comment #23
andrewmacpherson commentedRe: comment 22
Point 1:
This is not the case. If $logo_alt_text is a template variable, then it can be altered by any module/theme which implements hook_preprocess_page(), and changed to whatever the developer/themer chooses.
There's also no reason why we couldn't offer the $site_name (and/or slogan) as an option in the theme settings form. So it could be a choice of:
This sort-of echoes the current options for the logo and favicon images, with the main difference that we probably don't not want to offer a 'none' value for $logo_alt_text.
I don't necessarily think that all of these options should be in core; extra use-cases could be handled by contrib modules. It would require little more than hook_form_alter() and hook_preprocess_page().
Point 2:
I agree that's a problem, but in a wider context than $logo_alt_text. String localization in themes could be a powerful feature in general. It's worth raising this with the localization and configuration folks.
Comment #24
andrewmacpherson commentedRe: comment #15
Is it necessary to couple the custom alt text to the custom logo option? Are there any use-cases for choosing the logo provided by the theme, but overriding the theme-provided alt text with custom alt text?
Use of $site_name could be one. Another would a workaround to translate the theme-provided alt text.
Comment #25
andrewmacpherson commentedRe: comment 6
I'd be happy to do some more work towards a D7 version of this, either as a sub-module for the accessible helper project, or as a separate project. The momentum for getting this in core has rekindled my enthusiasm for a contrib module :-)
One problem, as I see it, is that my D6 module in #18 doesn't work out-of-the-box;. It requires a change to page.tpl.php
So if a site-builder has the logo_alt module enabled, and uses a theme from drupal.org contrib, they'll hit a brick-wall WTF unless they know how to change the page template. The best we can really do is provide thorough set-up documentation and/or raise awareness of the feature.
Having said that, I appreciate that the accessible helper modules goals include serving as a demonstration.
Comment #26
andrewmacpherson commentedI'm doing the #d5dChallenge, so I spent time on this today.
After a bit of messing around, I came up with an approach for the problem in comment #15, keeping it all in theme_get_setting(). We can treat it more like the way the favicon path is generated. Store logo_custom_alt_text from the form, the test toggle_logo and default_logo to decide whether to return the custom text from the form, the default text from the theme, or Home.
My code needs a tidy, so I'll aim to post a patch tomorrow evening.
Comment #27
Everett Zufelt commentedI postponed #1270598: Decide on appropriate alt text for default logo pending this issue being resolved.
The proposed solution in is to set the default logo alt to $site_name, so this issue needs to take that into account when developing the method of allowing themes to set their own default logo alt and allowing users to override on the theme settings form.
Comment #28
andrewmacpherson commentedAnother patch. Here's my take on things.
Comment #30
Everett Zufelt commented@andrewmacpherson
Before I dig into your patch too far, I'm wondering if you might have time to address the test notices?
Comment #31
andrewmacpherson commentedre-rolled patch, minor changes from comment 28.
Needs testing with settings provided by base themes.
Also I'd like to know what people think of the UI strings.
Comment #32
Everett Zufelt commentedbots?
Comment #33
dcmouyard commentedThe UI strings look good to me.
When specifying a Logo alternative text source and saving the form, the option gets shown as Site name when finished instead of what was chosen.
Creating a custom alt text and saving the form replaces the alt text correctly in the theme. Editing a theme's .info file to set a custom alt text and choosing Default alternative text provided by the theme, however, does not get applied correctly in the theme.
Comment #34
droplet commentedcan it either use logo_alt_text or logo_alt_custom_text
2 days to next Drupal core point release.
Comment #35
andrewmacpherson commented#31: logo-custom-alt-717708-31.patch queued for re-testing.
Comment #36
mgiffordI could use some clarification about logo_alt_text & logo_alt_custom_text too.
@andrewmacpherson this was introduced in the patch in #31 but would be good to have a bit more clarification on how it's used.
Comment #37
Jeff Burnz commentedWhy not use theme_image()?
Comment #38
mgifford#31: logo-custom-alt-717708-31.patch queued for re-testing.
Comment #40
mgiffordThis issue hasn't received consensus. Will re-open if someone wants to submit a new patch for review. It's a difficult use case where it is difficult to find where there is a good use case.
Comment #41
Everett Zufelt commentedWe should probably make sure that the method of providing custom alt text for a logo is documented.
Comment #42
jhodgdonWhere do you think the method for providing alt/title text needs to be documented? I'm assuming that the functions that were updated in this issue were documented properly in the API documentation, so probably you mean that some on-line Community Documentation pages need to be updated?
If so, the best thing to do is probably to either edit them directly, or leave this issue open in the Theme system component with status "needs work" and tag "needs documentation" until that is done.
Comment #43
andrewmacpherson commentedThe patch doesn't include any API documentation yet.
The
logo_alt_custom_textsetting was silly idea (just to get it working). Really it should just belogo_alt_text.I recall having trouble with the internals of theme_get_setting(). Due to the way it sets up an array of theme settings, a custom alt text would end up over-writing the text from a theme (or base theme). I tried a few ways, and none of them were pretty. It might be a good candidate for the clean-up initiative.
I'll try to find time to re-roll this soon. The current patch is from the days before /core directory anyways.
Comment #44
Everett Zufelt commentedThe accessibility maintainers have decided that this issue is won't fix. We do, however, think that the themeing guide should include an explanation of how to set the logo in page.tpl.php (or wherever it is stored).
Comment #45
jhodgdonIn that case, I am moving this to the Documentation issue queue.
Comment #46
mgiffordI can't recall if we'd decided that this issue here was also a won't fix - #1270598: Decide on appropriate alt text for default logo - would be good to either fix it or mark it closed.
Comment #46.0
mgiffordUpdated summary
Comment #47
mgiffordThere's no code to review, just documentation to write.
Comment #48
minneapolisdan commentedI created documentation over in Drupal theming, https://drupal.org/node/2281499. Does that resolve this issue?
Comment #49
mgiffordI think it is, thanks! We may open it up in the future, but our decision the last time we looked at it was to deal with it in documentation rather than code.
Comment #50
mgiffordwrong closed status.