0

I have an events page and I don't want screen readers to pay attention to the image links as each event already has a link associated with it. Having 2 links read out seems like overkill.

In my template.php file I've added this, but I must not have it right as it adds nothing. I'm trying to add role="presentation" to only the images on the event pages.

function mytheme_preprocess_node(&$variables) {
  if($variables['node']->type === 'event') {
  $variables['attributes']['role'] = 'presentation';
  }
}
  • 4
    Your code can't affect the attributes of images, as it's altering the variables for node. You'll want to preprocess the image field rather than the node. – Alfred Armstrong Oct 28 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.