I wanted to be able to choose which image size to display in the block. I know I could use the theme function, but it would be good to choose in the block configuration.

I actually made this change, but with the CVS tool I have I can't seem to create patches. All the changes I made are in the images_block function. Changed lines shown by ***:

function image_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$block[0]['info'] = t('Latest image');
$block[1]['info'] = t('Random image');

return $block;
case 'view':
if (user_access('access content')) {
switch ($delta) {
case 0:
$images = image_get_latest();
$block['subject'] = t('Latest image');
*** $block['content'] = theme('image_block_latest', $images, variable_get('block_image_latest_size', IMAGE_THUMBNAIL));
break;
case 1:
$images = image_get_random();
$block['subject'] = t('Random image');
*** $block['content'] = theme('image_block_random', $images, variable_get('block_image_latest_size', IMAGE_THUMBNAIL));
break;
}
}
return $block;
*** case 'configure':
*** $form = array();
*** $all_sizes = image_get_sizes();
*** foreach ($all_sizes as $key => $val) {
*** $options[$key] = $val['label'];
*** }
*** if ($delta == 0) {
*** $form['block_image_latest_size'] = array(
*** '#type' => 'select',
*** '#default_value' => variable_get('block_image_latest_size', IMAGE_THUMBNAIL),
*** '#title' => t('Select which image size to use in the block'),
*** '#options' => $options,
*** '#description' => t('Value selected from possible image sizes to show in the block.'),
*** );
*** } else if ($delta == 1) {
*** $form['block_image_random_size'] = array(
*** '#type' => 'select',
*** '#default_value' => variable_get('block_image_random_size', IMAGE_THUMBNAIL),
*** '#title' => t('Select which image size to use in the block'),
*** '#options' => $options,
*** '#description' => t('Value selected from possible image sizes to show in the block.'),
*** );
*** }
*** return $form;
*** case 'save':
*** if ($delta == 0) {
*** variable_set('block_image_latest_size', $edit['block_image_latest_size']);
*** } else if ($delta == 1) {
*** variable_set('block_image_random_size', $edit['block_image_random_size']);
*** }
*** return;

}
}

Anyway, I think it is a pretty useful feature, if someone else can create a patch, that would be good, if no one does, eventually I'm sure I'll figure it out.

Cheers,
Steph

Comments

sun’s picture

Status: Needs review » Needs work

Please provide a proper patch.

joachim’s picture

Status: Needs work » Postponed

This will be easily doable with http://drupal.org/node/220295

joachim’s picture

Status: Postponed » Closed (works as designed)

This should be made with views.
Closing as by design.