How to display the height and the width of the original image next to it's thumbnail

Permalink
Hello,
I can display thumbs of several images in a list. I can also display custom attributes (such as description, filetype and size) next to them. But I cannot display the default(!) attributes height and width of the original images in the file manager. It is nessesary to let the guest know the dimensions of the original file
This (for example)
<li> 
      <div style="float: left; width: 150px; "> 
         <?php  $im->outputThumbnail($f, 150, 250);?>
      </div>
      <div style="float: right; width: 300px; "> 
         <?php  echo $tip_text;?>
         <br>
         <?php  echo $f->getSize();?>
         <br>
         <?php  echo $f->getwidth();?>
         <br>
          <br>
         <br>
         <a href="<?php  echo $fv->getURL();?>">download</a></div>
      <div class="clear"></div>

returns
Warning: call_user_func_array() expects parameter 1 to be a valid
 callback, class 'FileVersion' does not have a method 'getwidth' 
in /home/urispcen/c5/concrete/core/models/file.php on line 35

So far so good, but what is the function to display width and height.
I am looking forward for your help people...
Best Mathias

1 Attachment

MathiasB
 
kirkroberts replied on at Permalink Best Answer Reply
kirkroberts
Mathias, perhaps you already figured this out, but if you use
echo $f->getAttribute('width');
echo $f->getAttribute('height');

you should get the file's original width and height.

Hope that helps!
MathiasB replied on at Permalink Reply
MathiasB
Dear Kirk!
It works perfect. Thank You! And it is soooo simple...
My last try was ...
<?php
list($width, $height, $type, $attr) = getimagesize("XXXXXXX.jpg");
echo "Image width " .$width;
echo "<BR>";
echo "Image height " .$height;
echo "<BR>";
echo "Image type " .$type;
echo "<BR>";
echo "Attribute " .$attr;
?>

... but it only works when I write the complete path into the code (XXX). I doesn't work with "getPath" or "getURL".
So I gave up...

Thank You!
Mathias
mhawke replied on at Permalink Reply
mhawke
MathiasB replied on at Permalink Reply
MathiasB
Hi!
Thank You.
Sorry. I also tried that. But it also doesn't work.
At all three options C5 displays (echo) the right path in the browser. When I copy the path from the browser and put it into the code, it works fine. But when I insert "$src = $f->getPath();" or one of the other options into the code, C5 displays the alert (see above). Maybe it is a bug.
Best
Mathias
mhawke replied on at Permalink Reply
mhawke
You will need to show us your entire code where the file object is being created. You are mixing standard PHP stuff (list, getimagesize) with C5 stuff (getRelativePath) and it's hard to tell where it's getting tripped up. Can you attach your entire php page? Rename it .txt so it will post in the forum.
MathiasB replied on at Permalink Reply
MathiasB
Unfortunately I replaced my "problem-code" with Kirks solution.

I forgot to tell you, that the problem-code was part of a template for the Add On "List Files from Set". Maybe that causes path problems.

Nevertheless the problem is solved for me now.
But I will try to rebuild that code tonight.

Best Mathias
mhawke replied on at Permalink Reply
mhawke
Hey, don't rebuild the code just for me. I have lots of other problems to mull over. I'm glad it's solved one way or another.
mhawke replied on at Permalink Reply
mhawke
I added the following code at around line 185 of the view.php file in the 'List Files From Set' add-on:

$dimensions = $f->getAttribute('width')." x ".$f->getAttribute('height');


and added this line just below the thumbnail output:

<div><?php echo $dimensions ;?></div>


Works great.