phppaginationdrupal-7

using image path returned by drupal 7


am unable to use the path returned by drupal 7 for an image which was uploaded for custom content type. the path returned is as follow:

Array ( [und] => Array ( [0] => Array ( [fid] => 6 [alt] => [title] => [width] => 464 [height] => 261 [uid] => 1 [filename] => _71135631_c0166859-snotty_child_with_a_cold-spl.jpg [uri] => public://_71135631_c0166859-snotty_child_with_a_cold-spl.jpg [filemime] => image/jpeg [filesize] => 22168 [status] => 1 [timestamp] => 1384797114 [rdf_mapping] => Array ( ) ) ) )

but when using the vale of uri, the image is not shown.

any assistance appreciated.

regards, a.ali


Solution

  • Such uri-fields in Drupal always refer to the internal data-storage logic, hence the public:// at the beginning. Drupal uses Image Styles for any images attached to content.

    To retrieve the full URL for an image, you should use image_style_url():

    $imgPath = image_style_url('default', $object['und'][0]['uri']);