'left+10', 'ypos' => 'bottom-10', 'textstyle' => array( 'fontfile' => drupal_get_path('module', 'imageapi_text') . '/fonts/liberation-fonts-1.04/LiberationSans-Regular.ttf', 'style' => "font-size:12px;\nfill:#333333;\ntop:10px;\nright:10px;", ), 'text' => 'Hello World!', 'evaluate_text' => FALSE, ); // Our 'textstyle' parameter is a nested array - reflecting the wiget fieldset structure // only because imagecache sets the form // #tree to true, and unsetting it doesn't work. $action = array_merge($defaults, (array)$action); $form = array( 'textstyle' => imageapi_text_style_widget($action['textstyle']), 'text' => array( '#type' => 'textarea', '#rows' => 7, '#title' => t('Text'), '#default_value' => $action['text'], '#description' => t('The text string. If you are using a WYSIWYG editor, you should disable it for this field!'), '#wysiwyg' => FALSE, ), 'evaluate_text' => array( '#type' => 'checkbox', '#title' => t('Evaluate text as PHP code'), '#default_value' => $action['evaluate_text'], '#description' => t('If selected, the text will be treated as PHP code.

Enter PHP code that will return your dynamic text. Do not use %php tags.
EG return format_date(time());
return $file_data->description ? $file_data->description : $node->title;

Note that executing incorrect PHP-code can break your Drupal site.

If it\'s an image.module image then a $node object with its values may be available.
return $node->title;
return format_date($node->created);

If it\'s an image that has been attached to a node using CCK-filefield-imagefield (or just filefield) then as well as the parent $node object, a $file_data object that may contain a file description from that file field.
return $file_data->description; So far that seems to be the only available \'data\' provided by filefield, but you can investigate the node structure using devel.module or print_r() to see what else this array actually contains.

If it\'s a file that\'s just been attached using upload.module, a $file_data object may also have a description.
return $file_data->description;

If the image path is detected as belonging to more than one node, just the data for the first one found is returned.

An "$image" object is also available, but that usually contains only technical data, including
return $image->source;
return basename($image->source);
return $image->info["filesize"];

', array('%php' => '')) ), ); if (! user_access('administer site configuration')) { $form['evaluate_text']['#disabled'] = TRUE; $form['text']['#disabled'] = $action['evaluate_text']; // lock this if an admin has enabled evaluation. $form['evaluate_text']['#description'] = 'requires administer site configuration permissions.'; } #$form['#tree'] = FALSE; #$form['textstyle']['#tree'] = FALSE; return $form; } /** * Implementation of theme_hook() for imagecache_ui.module */ function theme_textactions_rendertext($element) { $data = $element['#value']; $style_atts = imageapi_text_parse_style($data['textstyle']['style']); return "{$data['text']}
{$data['textstyle']['style']}" ; } /** * Place the source image on the current background * * Implementation of hook_image() * * @param $image * @param $action */ function textactions_rendertext_image(&$image, $action = array()) { if (!empty($action['evaluate_text'])) { $text = textactions_evaluate_text($image, $action); } else { $text = $action['text']; } $style = imageapi_text_parse_style($action['textstyle']['style']); $fontfile = $action['textstyle']['fontfile']; // Calculate position by first creating a temp image // containing the text and accessing its dimensions // $textimage is a placeholder that will get the image created in it - to work like the rest of the imageapi functions. // We really need to force the toolkit to GD, but even then it can't be merged back into imagemagick $textimage = (object) array( 'toolkit' => $image->toolkit, ); if(! imageapi_image_create_text($textimage, $text, $fontfile, $style) ) { drupal_set_message(t('Failed to generate text image using %toolkit. Not overlaying text.', array('%toolkit' => $textimage->toolkit )), 'error'); return FALSE; } // $textimage should now have its size info available. // Calc the position if (!empty($style['top'])) { $ypos = $style['top']; } if (!empty($style['bottom'])) { $ypos = $image->info['height'] - ( $textimage->info['height'] + $style['bottom']); } if (! isset($ypos)) { // assume center $ypos = ($image->info['height']/2) - ($textimage->info['height']/2); } if (!empty($style['left'])) { $xpos = $style['left']; } if (!empty($style['right'])) { $xpos = $image->info['width'] - ( $textimage->info['width'] + $style['right']); } if (! isset($xpos)) { // assume center $xpos = ($image->info['width']/2) - ($textimage->info['width']/2); } return imageapi_image_overlay($image, $textimage, $xpos, $ypos); //////////////////////////////// }