"(no imagecache process)"); foreach($presets as $preset) { $imagecache_options[$preset['presetid']] = $preset['presetname']; } foreach(element_children($form['image_sizes']) as $key){ $form['image_sizes'][$key]['imagecache'] = array( '#type' => 'select', '#default_value' => $sizes[$key]['imagecache'], '#options' => $imagecache_options, ); $form['image_sizes'][$key]['operation']['#type'] = 'hidden'; $form['image_sizes'][$key]['width']['#type'] = 'hidden'; $form['image_sizes'][$key]['height']['#type'] = 'hidden'; } $form['image_sizes']['#description'] .= t('
Note: \'Original\' dimensions will only be used to resize images when they are first uploaded. Existing originals will not be modified. Choose an imagecache preset to use to generate this derivative image.
', array('!imagecache_settings' => url('admin/build/imagecache')) ); $form['image_sizes']['#theme'] = 'imagecache_image_settings_sizes_form'; // Capture the form submission so we can save this setting $form['#submit']['imagecache_save_image_size_settings'] = array(); } } function theme_imagecache_image_settings_sizes_form(&$form) { $header = array(t('Label'), t('Imagecache Preset'), t('Link')); foreach (element_children($form) as $key) { $row = array(); $row[] = drupal_render($form[$key]['label']); $row[] = drupal_render($form[$key]['imagecache']); $row[] = drupal_render($form[$key]['link']); $rows[] = $row; } $output .= theme('table', $header, $rows); $output .= drupal_render($form); return $output; } /** * Implementation of hook_image_alter() * * Capture the image_build_derivatives phase of image.module * and insert our own manipulations to it any time an image is manipulated. * * This runs the imagecache builder over the input file and places it in the * output destination. */ function imagecache_image_alter($node, $destination, $sizename) { $sizes = image_get_sizes(); $size_def = $sizes[$sizename]; // Appended to the dimensions is our 'imagecache' id value. Maybe. if ($presetid = $size_def['imagecache']) { $original = file_create_path($node->images['_original']); $preset = imagecache_preset($presetid); $result = imagecache_build_derivative($preset['actions'], $original, $destination ); } }