By horizens on
I need to calculate the dimensions of an image that is created through CCK and then displayed in a view. The objective is to allow a user to upload an image and then display the image width and height along with the caption and other image details. Like you might see on a stock photo site.
Any suggestions how to do this? Thanks!
Comments
Computed Field?
I've tried looking at Computed Field, but I'm not great with PHP yet and I couldn't get this to work:
$image = open_image($node->field_image[0]['filepath']);
$node_field[0]['value'] = imagesx($image);
If You Use...
If you use imagefield then this information is already available to you. Take a look at this...
See up in like the second line of the function? You have all these values available to you and already in variables. Sweet!
BTW, this code is right out of the imagefield module
Well hope that helps, if not hollar back.
Peace,
-mpare
www.paretech.com
Did you figure out how to do something? Did you find documentation on Drupal.org inadequate? Well now it's your turn. Document your Success!
That is very helpful. Thanks
That is very helpful. Thanks for pointing me in the right direction. I'm still a little confused as to how to display the variable on the view page though. Would you do this with computed fields? Or is there an easier way?
Thanks!
Does anyone have an idea how
Does anyone have an idea how to implement this? Thanks.
Hi horizens, I hope you've
Hi horizens,
I hope you've already found the solution (8 March...). Otherwise, simply add :
before "$attributes = drupal_attributes($attributes);"
Hi,Need some help for a
Hi,
Need some help for a similar case... I need to display image's original dimension (like "1024x768") under thumbnail in a view. I use imagefield and I've tried using computed field without success to implement this.
Is computed field the good solution? what is the right computed code to add?
Webastien, what is the effect of your code in the imagefield module? How display the value in the view with your method?
thanks
Solved. Finally the line
Solved.
Finally the line given by jpetso (http://drupal.org/node/259351) works too when put at top of the computed code :
list($width, $height, $type, $image_attributes) = @getimagesize($node->field_mycontenttype[0]['filepath']);Thanks