Impostare Stile immagine da Codice

Usando la funzione theme() mi basterà prendere l'uri del file immagine e il nome dello stile da applicare:

print theme('image_style', array('path' => $node->field_image[LANGUAGE_NONE][0]['uri'], 'style_name' => [STYLE NAME]));

 

Esempio:

Se volessi stampare l'avatar di un utente potrei scrivere:

<?php
        $user = user_load($node->uid);
        print theme('image_style', array('path' => $user->picture->uri, 'style_name' => 'thumbnail__50x50_'));

?>
Subscribe to Style