Skip to content

Instantly share code, notes, and snippets.

@samuelsolis
Created April 8, 2014 09:22
Show Gist options
  • Save samuelsolis/10103907 to your computer and use it in GitHub Desktop.
Save samuelsolis/10103907 to your computer and use it in GitHub Desktop.
Preprocess field in Display Suite module, Drupal 7 example.
/*
* Before this, you have to create a "Preproces field" with name like "mycustomfield".
* In this example we render an user image (a image field, not the user picture).
*
*/
function MYMODULE_preprocess_comment(&$vars){
$author= user_load($vars['user']->uid);
$settings= array('settings' => array('image_style' => 'thumbnail'),'label' => 'hidden' );
$vars['mycustomfield'] = render(field_view_field('user', $author, 'field_user_main_image', $settings));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment