Skip to content

Instantly share code, notes, and snippets.

@fragje
Created April 20, 2012 21:02
Show Gist options
  • Save fragje/2431872 to your computer and use it in GitHub Desktop.
Save fragje/2431872 to your computer and use it in GitHub Desktop.
drupal php: ds custom field example code
<?php
print_r($entity);
print_r($entity->field_attachment);
echo $entity->field_company_rl[LANGUAGE_NONE][0]['display_url'];
echo $entity->field_attachment[LANGUAGE_NONE][0]['uri'];
// Print url from uri if it's valid
$uri = $entity->field_attachment[LANGUAGE_NONE][0]['uri'];
if(!empty($uri)) {
print file_create_url($uri);
}
// Check if module image exists
if(module_exists('image')) {
// Check if image_field has value
if(!empty($entity->field_image)) {
//Pring image with medium image style
$img_path = $entity->field_image[nn][0]['uri'];
print theme_image_style(array("path" => $img_path, "style_name" => "medium");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment