I'm am passing image field data in a Flash piece with AMFPHO and Services and would like to add some additional information to the field array. Namely, the image's height and width.
My initial thought is that perhaps I can accomplish this with a preprocess function within my template.tpl.php file and change the array output. After trying and failing all day I thought I might see if anyone could point out my (probably glaring) mistake/s.
function mythemename_preprocess_imagefield_image(&$variables) {
$variables['width'] = "width will go here";
$variables['height'] = "height will go here";
}
Above is a test I put in place just to see if I could effect the array and change this...
[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
)
)
...to this...
[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
[width] => width will go here
[height] => height will go here
)
)
Needles to say it has not worked, and I'm wondering if its the wrong hook, or something more. I swear I've been scoring the web to search for a comprehensive list of preprocess hooks. I'm not finding much for fields. Is it even possible? I'm clearly a bit over my head. :(
Any advice would be very appreciated. Thank you for reading!
Comments
Are you sure the hook is
Are you sure the hook is called? (I add something like drupal_set_message("You are here"); as the first line in the function to check)
Thank you for taking the time
Thank you for taking the time to respond Nevets!
I am not sure it is being called. That is part of the problem I suppose. I'm just keep checking the field array output for a change and I'm not seeing one.
Previously I had stuck in a print "working"; commands to see if it changed anything visually on the site. Nothing changed.
I just tried adding your "drupal_set_message("You are here");" Nothing changed either.
That means your hook is not
That means your hook is not being called, I was playing with something recently and had the same problem but in my case took another approach. I suspect it has to do with the theme registry but have not had time to track it down. I suspect you may need to use hook_theme() but have not figured how to register a preprocess function.
Thank you again for your
Thank you again for your thoughts.
The more I research this the more I think what I am trying to do may simply not possible. The following quote is from the Drupal theming guide and it seems to be saying that preprocess funcs only work in pairs with tpl.php files?
If that is correct, then I think I'm doing this all wrong. After all, I'm not trying to change the output or markup of the image field. I'm trying to change the array itself.
*shrug*
You are right that I don't understand hook_theme(). You mean this I suppose:
If so, then yes I am actively using it, but I have no clue what it all means. Earlier I did try the following as a stab in the dark to see if it would help...
But it didn't. Needles to say I was just guessing as to what the values/arguments should be. One of the things I find confusing is that some preprocess functions don't seem to require registering like this? Like "mythemename_preprocess_page" which I'm using. But perhaps it is inheriting its registration from the parent theme? I'm using Zen.
Anyway, thank you for responding... I am trying :)