PDA

View Full Version : image sizing to real width and height


kabkab
09-06-2011, 04:13 PM
Hi,
In order to be "correct" with the advices of pagespeed which suggest to specify the width and the height of the images I wonder if it possible to do that.

like this

<img alt="the image" src="http://www.mysite.com/img/summary_medium/photos/Phot01.jpg" width="84" height="100">

and in my tpl

<img src="{VIVVO_STATIC_URL}img/summary_medium/{article.get_image}" alt="{image_caption}" width="{the_width}" height="{the_height}"/>

where the values of the_width and the_height could be returned by thumbnail.php

Micha
09-07-2011, 08:13 AM
Only if all your images are same in aspect ratio.
If you have for example few of them in 4:3, than few of them in 16:9, 1:1, 16:10, than you can't use thumbnail because you'r images will get distorted.

If you use same aspect ratio, than you could use something like this:


<img src="{VIVVO_STATIC_URL}thumbnail.php?file={article.imag e}&amp;size=article_medium" alt="{image_caption}" width="{VIVVO_ARTICLE_MEDIUM_IMAGE_WIDTH}" height="{VIVVO_ARTICLE_MEDIUM_IMAGE_HEIGHT}" />

or any other image size (article_small, summary_medium).

kabkab
09-07-2011, 01:29 PM
Hi,
Thanks Micha for your answer.
I understood that "limitation". In fact my images are with different sizes. So it's impossible to do what I need?