Get fid from file path I've to create a custom function to display images because I've to add values from custom fields.

I've added a function to template php, like this:

function mytheme_image($variables) {  
}


The problem is that in $variables I haven't the fid of the file, but only the path. I have to load the file to get values from field, how should I do?

I'm looking for functions to get fid from path but I haven't found something..
@pvorb, you can also use EntityFieldQuery.  See the first comment on https://api.drupal.org/api/drupal/includes%21file.inc/function/file_load_multiple/7 for an example.  Something along the lines of:

$filename = 'myfirstpony.png';
$query = new EntityFieldQuery();
$result = $query-&gt;entityCondition('entity_type', 'file')
  -&gt;propertyCondition('filename', $filename)
  -&gt;execute();
// if you are guaranteed there is exactly one result, then:
$file_object = reset($result['file']);
$fid = $file_object-&gt;fid;
// but beware you might get 0 or many results


If you have more information -- such as the path (from which you can generate a URI) -- then change the query condition to something like -&gt;propertyCondition('uri', 'public://path/to/myfirstpony.png').