Getting width/height of pictures in "singleBody view&qu

cschlatt

Joined: 2005-05-24
Posts: 17
Posted: Thu, 2005-06-02 12:37

I'd like to wrap photos in the singleBody view in a <div> with fixed width. Now the question is, how to get the actual width of the photo that gets displayed. From the smarty debug info, I constructed the following:

... inside singleBody.tpl:
{$layout.imageViews[$layout.imageViewsIndex].width}

That works for now, but is this method safe to use (e.g. are there situations where the $imageViews array is empty?).

Thanks,
Christian

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2005-06-02 14:38

It could be empty, but unlikely as it will even show you the thumbnail if you don't have permission to view full size or resizes. But another possibility is a non-image so there is no ".wdith". Look at the top of the tpl where it makes a shortcut to $layout.imageViews[$layout.imageViewsIndex] and assigns it to "image".. you can use {if !empty($image.width)} .... {$image.width} .... {/if}