batamcityinfo / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

Any way to add width & height attributes to the generted image? #267

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When an image is generated with TimThumb, it does not include any height or 
width attributes. This can cause a page layout to shift once the images have 
loaded. It would be great if there were a way to get the height and width of 
the generated image so we could include that in the <img> tag.

Cheers,
Dalton

Original issue reported on code.google.com by dal...@madebyraygun.com on 22 Sep 2011 at 7:16

GoogleCodeExporter commented 9 years ago
I don't understand how this is an issue. You specify the height and width when 
you size the image, so you know what to set the image width and height to.

Original comment by BinaryMoon on 25 Sep 2011 at 9:36

GoogleCodeExporter commented 9 years ago
Say you have a series of images that you need to fit in one dimension (all 
600px wide) but the height can be variable. So you call TimThumb with the width 
attribute, and they are all returned at that width, but at various heights. It 
would be good to be able to know what that height is in advance so you can 
apply those attributes to the <img> tag.

Height and width attributes are important for layout and also for DOM 
manipulation with javascript. But since this is probably not a problem that 
many people experience, I'll probably just build a function outside of TimThumb 
to do it. Pär Thernström wrote a function previously for this but I found 
that it sometimes reported the values incorrectly. 
http://eskapism.se/blogg/2010/10/create-timthumb-img-tags-with-correct-with-and-
height-attributes-with-this-simple-function-for-wordpress/

Thanks,
Dalton

Original comment by dal...@madebyraygun.com on 26 Sep 2011 at 2:42

GoogleCodeExporter commented 9 years ago
I don't think this is something TimThumb can or should do. It generates images 
and has no way to return values to a separate script.

Original comment by BinaryMoon on 8 Oct 2011 at 7:55