Hello,

Does the image field record an uploaded image's width or height? I noticed that I am able to restrict image size when I configure a field. So I was hoping it would make note of the width and height, which I happen to need for my site.

However, when I look at the field's array I don't see it:

[field_portfolio_image] => Array
        (
            [0] => Array
                (
                    [fid] => 30
                    [list] => 1
                    [data] => Array
                        (
                            [description] => 
                            [alt] => 
                            [title] => 
                        )

                    [uid] => 1
                    [filename] => psaw_idMaster.jpg
                    [filepath] => sites/all/files/portfolioImages/psaw_idMaster.jpg
                    [filemime] => image/jpeg
                    [filesize] => 37903
                    [status] => 1
                    [timestamp] => 1238743283
                )

        )

If it is not recorded in the array by default, do you know of any way to possibly add it? One less elegant work around I thought of was to manually include the values in the file name and just parse it. But I figured it would be smart to ask in case something already exists in the CMS.

Thank you so much for reading. I appreciate any insight you might have!

Comments

mm167’s picture

u may call the drupal function :
$result = image_get_info($file)

buy me a beer, then check the $result['width'] and $result['height'] ...

enjoy..

ecksley’s picture

Thank you kindly for the answer.

I'm actually trying to pull the values into a Flash piece using AMF PHP/Services. That said I'll need to look into using your trick to change the field array output.

Maybe some sort of reprocess function adding a key for height and width? But that's another problem for another day.

Thank you again!

mm167’s picture

looks u want to know the image width and height to build your bmp buffer in your flash ..

any way..good luck ..

ecksley’s picture

That's exactly right. If I have success I will be sure to post it here.

Thanks so much for your help!

ecksley’s picture

Thanks to a tip from Nate Haug I have found an easy solution to this problem. Figured I'd post it here for those like me that didn't know:

Simply enabling the filefield_meta.module, which comes with filefield will provide the height and width data for every image loaded thereafter in the $node->field_image[0] array.