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)
returns
So far so good, but what is the function to display width and height.
I am looking forward for your help people...
Best Mathias
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>
Viewing 15 lines of 16 lines. View entire code block.
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
Dear Kirk!
It works perfect. Thank You! And it is soooo simple...
My last try was ...
... 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
It works perfect. Thank You! And it is soooo simple...
My last try was ...
... 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
Try this:
$src = $f->getRelativePath();
http://www.concrete5.org/community/forums/customizing_c5/image-file...
$src = $f->getRelativePath();
http://www.concrete5.org/community/forums/customizing_c5/image-file...
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
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
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.
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
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
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.
I added the following code at around line 185 of the view.php file in the 'List Files From Set' add-on:
and added this line just below the thumbnail output:
Works great.
$dimensions = $f->getAttribute('width')." x ".$f->getAttribute('height');
and added this line just below the thumbnail output:
<div><?php echo $dimensions ;?></div>
Works great.
you should get the file's original width and height.
Hope that helps!