Skip to main content
added 14 characters in body
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

There is no need for manual queries.

You can load a file using file_load($fid)file_load($fid), and then the path is is in $file->uri$file->uri. MightIt might look a bit stringe ('public://something.jpg'), but that's a so called stream wrapper, and it works just fine with plain PHP file functions.

It's not exactly clear to me what you are trying to achieve,achieve; if you want to render an image field from a node/user/..., there are better ways to embed title and things like that, but this would work if you really just have a field. (That you are trying to query the field data table suggests otherwise, though).)

<?php
  $file = file_load($fid);
  $variables = array(
    'path' => $file->uri,
    'style_name' => 'your_style_name',
  );
  print theme('image_style', $variables);
?>

There is no need for manual queries.

You can load a file using file_load($fid) and then the path is is in $file->uri. Might look a bit stringe ('public://something.jpg'), that's a so called stream wrapper and works just fine with plain PHP file functions.

It's not exactly clear to me what you are trying to achieve, if you want to render an image field from a node/user/..., there are better ways to embed title and things like that, but this would work if you really just have a field (That you are trying to query the field data table suggests otherwise, though).

<?php
  $file = file_load($fid);
  $variables = array(
    'path' => $file->uri,
    'style_name' => 'your_style_name',
  );
  print theme('image_style', $variables);
?>

There is no need for manual queries.

You can load a file using file_load($fid), and then the path is in $file->uri. It might look a bit stringe ('public://something.jpg'), but that's a so called stream wrapper, and it works just fine with plain PHP file functions.

It's not exactly clear to me what you are trying to achieve; if you want to render an image field from a node/user/..., there are better ways to embed title and things like that, but this would work if you really just have a field. (That you are trying to query the field data table suggests otherwise, though.)

<?php
  $file = file_load($fid);
  $variables = array(
    'path' => $file->uri,
    'style_name' => 'your_style_name',
  );
  print theme('image_style', $variables);
?>
Source Link
Berdir
  • 83.5k
  • 6
  • 161
  • 207

There is no need for manual queries.

You can load a file using file_load($fid) and then the path is is in $file->uri. Might look a bit stringe ('public://something.jpg'), that's a so called stream wrapper and works just fine with plain PHP file functions.

It's not exactly clear to me what you are trying to achieve, if you want to render an image field from a node/user/..., there are better ways to embed title and things like that, but this would work if you really just have a field (That you are trying to query the field data table suggests otherwise, though).

<?php
  $file = file_load($fid);
  $variables = array(
    'path' => $file->uri,
    'style_name' => 'your_style_name',
  );
  print theme('image_style', $variables);
?>