I'm attempting to pull in the filepath of an image attached to a node for use in a custom field in views. I've added Content: Image - Path to File and when 'exclude from display' is unchecked, I'm seeing the exact data (the filepath) that I need. However, there doesn't seem to be a variable associated with $data that I'm seeing to use this info.

I've managed to successfully wrangle this info inside a node.tpl.php file by using $field_image_cache['0']['filepath']. What is the equivalent of this for using with $data in custom field?

Am I using the wrong field? I've tried everything I can think of and each of them are ordered before the Customfield: PHP code.

Thanks in advance.

Comments

ibloomdrop’s picture

Status: Active » Closed (fixed)

Stumbled over the answer and it works. For anyone else having a similar problem, I added the following code to my custom php:

 $file = field_file_load($data->node_data_field_image_cache_field_image_cache_fid[0]['fid']);
$img = $file['filepath'];

Then substituted $img where I needed it and it works. Maybe there's a cleaner way, but this is how I did it.