Hi,

I'm validating my html5 site and I'm having a problem with a "typeof" atribute. This atribute is beeing used in my views slideshow.

Does anyone know what typeof does and how I can remove/validate it?

<img typeof="foaf:Image" src="http://www.mysite.com/sites/default/files/styles/thumbnail/public/featured.jpg" width="125" height="80" alt="" />
W3C HTML5 => Attribute typeof not allowed on element img at this point.

This is the only validation problem I have, so I really would like to get rid of it. So help is very appreciated! Thanks!

Comments

stborchert’s picture

Issue tags: +dvcs11

Hi.
I think this is more a problem of your validator than of views :)
The property "typeof" comes from RDFa. If you'd like to remove this you'll have to override the function theme_image in your theme and remove it from $variables['attributes'].

Please set the status of this issue to "fixed" if this solves your validation issues.

DriesP’s picture

Thanks for helping me on this one. Al though I'm gonna need a little more help as I am not well home in php.

function MYTHEME_image($variables) {
  $attributes = $variables['attributes'];
  $attributes['src'] = file_create_url($variables['path']);

  foreach (array('width', 'height', 'alt', 'title') as $key) {

    if (isset($variables[$key])) {
      $attributes[$key] = $variables[$key];
    }
  }
  return '<img' . drupal_attributes($attributes) . ' />';
}

How do I remove the 'typeoff' attribute? I can't figure it out. Thanks.

dawehner’s picture

If you really want to remove it do

 unset($attributes['typoeof']);
scor’s picture

Status: Active » Closed (works as designed)

At the time the HTML5 validator was probably very experimental/unfinished. The typeof attribute validates now in HTML5, see results.

jwilson3’s picture

Issue summary: View changes

This is also problematic for validating feeds with embedded images.

The w3c validator for feeds explicitly does not allow "typeof" attribute inside <description> so if you have RDF module enabled, and are embedding images into your feed item descriptions, the feed does not validate, and potentially causes problems with feed readers who implement to spec.

Unfortunately, out of the box with views in Drupal 7, there is no way to rewrite the img tag by hand because the image url is not one of the tokens provided in views . You can use https://www.drupal.org/project/image_url_formatter or do the heavy handed solution above implementing theme_image() in your theme, but this will affect and remove the typeof "foaf:Image" across the entire site.