Recomenda-se usar hook_node_insert () e hook_node_update () e verificar se as derivadas de imagem necessárias não foram geradas e, em seguida, gere-as, caso contrário, não faça nada.
/**
* Implements hook_node_insert to generate derivative images for the new inserted node in
* case they are not generated
* @param object $node
*/
function YOUR_MODULE_node_insert($node) {
//REPLACE field_YOUR_IMAGE_FIELD WITH YOUR FIELD IMAGE NAME
if(isset($node->field_YOUR_IMAGE_FIELD['und'][0]['uri'])) {
_generate_image_style($node->field_YOUR_IMAGE_FIELD['und'][0]['uri']);
}
}
/**
* Implements hook_node_update to generate derivative images for the new updated node in
* case they are not generated
* @param object $node
*/
function YOUR_MODULE_node_update($node) {
//REPLACE field_YOUR_IMAGE_FIELD WITH YOUR FIELD IMAGE NAME
if(isset($node->field_YOUR_IMAGE_FIELD['und'][0]['uri'])) {
_generate_image_style($node->field_YOUR_IMAGE_FIELD['und'][0]['uri']);
}
}
/**
* Generates the needed image styles by the image uri if they are not already generated
* @param string $image_uri
*/
function _generate_image_style($image_uri) {
//This should be changed to your image styles names.
$image_styles = array('image_style_name1', 'large_image', 'promo_image');
foreach ($image_styles as $style) {
$derivative_uri = image_style_path($style, $image_uri);
file_exists($derivative_uri) || image_style_create_derivative(image_style_load($style), $image_uri, $derivative_uri);
}
}
Nota: Se o seu campo de imagem capturar várias imagens, você deverá fazer um loop através delas assim:
if(isset($node->field_main_image['und']) && is_array($node->field_main_image['und'])) {
foreach($node->field_main_image['und'] as $delta => $image_field) {
_generate_image_style($node->field_YOUR_IMAGE_FIELD['und'][$delta]['uri']);
}
}
A geração de estilos de imagem é tirada daqui