Skip to content

Instantly share code, notes, and snippets.

@soulston
Created October 4, 2012 15:22
Show Gist options
  • Save soulston/3834348 to your computer and use it in GitHub Desktop.
Save soulston/3834348 to your computer and use it in GitHub Desktop.
Drupal 7 load an image from a field
<?php
$image = field_get_items('node', $node, 'my_field_name')) {
// current is just a quick way to get the first item in the array - you would probably array_pop here or just call
// $image = $image[0];
$image = current($image);
$image_uri = $image['uri'];
// Run the image through image styles.
$image = image_style_path('profile-small', $image_uri);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment