3

YSlow advises that all images should have dimension attributes even if they are presented at 1:1 scale, so that the browser knows the dimensions before the images are loaded, to start rendering the page faster.

I have a view of 20 taxonomy titles and their image fields. How I can make Drupal put their dimensions attributes on each image html tag?

I have drupal 7.

  • Which version of drupal are you referring to? Tag it. – mikeytown2 May 26 '11 at 0:53
  • The problem is that these images are most likely generated through image styles, which means that they might not even exist in the target size yet and it is configurable in the UI. And when you start to add code to detect the image size, you would probably very quickly spend more time doing that than you would gain in the browser by adding that information. That is just a guess, though :) – Berdir May 26 '11 at 8:39
  • i found that google mod_pagespeed module for apache can do that. but it's a pity to add an extra compontent to the system just for that. and what about the people that don't use apache anyway – john Jun 1 '11 at 22:49
2

This is a known issue in Drupal 7. A conscious choice, as it were, from the issue Remove unnecessary I/O from theme_image().

There is a patch to fix this here: Images are not printed with height and width.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.