source as the filename, * * $image->info array * * $image->res handle on the image object * * @param $action array of settings as defined in your form. * *******************************************************8 * Implementation of hook_imagecache_actions(). * * Declare available actions, return help text about this filter. * * These funcs are all in their respective include libraries - as configured below */ function imagecache_customaction_imagecache_actions() { $actions = array( 'imagecache_customaction' => array( 'name' => t('Custom action'), 'description' => t('Runs custom PHP code'), ), ); return $actions; } /** * Need to flush the cache when this module is enabled */ function imagecache_customaction_install() { imagecache_action_definitions(TRUE); drupal_set_message(t('Additional imagecache actions should now be available in the presets !settings_link', array('!settings_link' => l(t('settings'), 'admin/build/imagecache')))); } /** * * Implementation of imagecache_hook_form() * * @param $action array of settings for this action * @return a form definition */ function imagecache_customaction_form($action) { $form = array( 'text' => array( '#type' => 'textarea', '#rows' => 7, '#title' => t('Text'), '#default_value' => $action['text'], '#description' => t('

Enter PHP code for your custom action. Source image is available in $customaction_image variable. Your code must return image object (see ImageAPI).

Do not use %php tags.

Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '')) ) ); return $form; } /** * * Implementation of hook_image() * * * @param $image * @param $action */ function imagecache_customaction_image($image, $action) { // Process the php using drupal_eval (rather than eval), but with GLOBAL variables, so they can be passed successfully $GLOBALS['customaction_image'] = $image; $result = drupal_eval('<'.'?php global $customaction_image; '.$action['text'].' ?'.'>'); //$result = eval($action['text']); return $result; } /** * Implementation of theme_hook() for imagecache_ui.module */ function theme_imagecache_customaction($element) { $data = $element['#value']; return "". $data['text'] ."" ; }