You should think about changing your settings relating to imagecache to include only actual imagecache presets.

You should not create settings for image sizes otherwise in your spin box. The spinner should display for selection only imagecache presets

This way users will not have to go back into permissions and make assignments. This is just another step to prevent support issues with users.

In other words, users must make image cache presets first before using your module. Then they must make user permissions for imagecache viewers.

This way there is consistency in images. I realize users can still resize the image, but at least they start at a preset image size.

Comments

eugenmayer’s picture

Well in BETA4 i included 2 imagecache preset which are presets, but programmatically added (big, original). Do you mean them

domineaux’s picture

Yes, do not create presets in your imageupload program. Use the presets from Imagecache and users will have uniformity in choices. This will make it easy to follow through for all users.

I have Ubercart installed on a couple of sites and UC has narrative presets for Imagecache built into the UC. This is a royal pain, because users have to think narrative term "product_image" = 200x200 pixels imagecache size, etc.

An excellent way to manage imagecache presets is very simple 85x85 = 85px x 85 px, 100x100 = 100px x 100px, etc.

eugenmayer’s picture

Status: Active » Fixed

Fixed in BETA5

eugenmayer’s picture

Status: Fixed » Closed (fixed)
alan d.’s picture

Version: 6.x-1.0-beta4 » 6.x-1.0-rc1
Category: support » bug
Priority: Critical » Normal
Status: Closed (fixed) » Needs review

The code here seems to have a logical error.

Eg:

1) If no presets, then the module adds two

2) The user uses the presets provided by the module

3) The user / module creates a preset

4) The system flushes the presets, the original / big presets disappear

5) The presets used by the user already are now invalid

Workarounds

a) Make the special case that there may be one option that uses the original image.

OR

b) Create one (or more) presets that are always available

Cheers

eugenmayer’s picture

Hello Alan,

well thats a good point. My idea was to make the installation easier and work OOTB. But seeing your case, i have only 2 options.

1. Creating presets which stay in the system (that could most likely anoy people)
2. Not creating those at all. So one part of the wyswyg_imageupload installation is creating those presets

I really tend to case 2 seeing your valid point. What do you think?

eugenmayer’s picture

Status: Needs review » Fixed

Well actually there is not much to decide. The case of "not deleteable presets" is just to anoying. I guess there is a hack, using a submodule for this, which users can deactivate by need but still those presets get invalid afterwards. So i better remove them and update the configuration guide.

Fixed in rc2

alan d.’s picture

Same feeling here. It just requires a simple check on the preset count on the selection form, something like:

<?php
Index: wysiwyg_imageupload.form.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg_imageupload/Attic/wysiwyg_imageupload.form.inc,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 wysiwyg_imageupload.form.inc
--- wysiwyg_imageupload.form.inc	26 Jan 2010 01:46:20 -0000	1.1.2.5
+++ wysiwyg_imageupload.form.inc	30 Jan 2010 10:49:41 -0000
@@ -78,7 +78,8 @@
       '#type' => 'select',
       '#title' => t('Size'),
       '#options' => $styles,
      '#default_value' => $defaults['preset']
+      '#access' => count($styles),
     );
   }
?>

Cheers

eugenmayer’s picture

Well wont be only that, also the JS part needs to no that "no preset" is possible. In addition, the show ajax handler should be aware of this alternative also.

eugenmayer’s picture

Status: Fixed » Closed (fixed)
alan d.’s picture

Hi Eugen

I had a similar imagecache catch-22 on another project, and I think that I have a reasonable workaround. It is a bit more complex than you probably need, but hopefully it may give you some alternative ideas. I'm not sure how far back the schema goes, but it is working fine on my local install with up to date image modules.

Cheers

Alan

<?php
/**
 * Test the existence of a preset, and creates one if it doesn't exist.
 * @param $presetname string
 *  The ImageCache preset name.
 * @param $target string
 *  The section settings, e.g. 'gallery' or 'listing'.
 * @return $presetname string
 */
function userphotos_check_preset($presetname, $target) {
  $presets = imagecache_presets();
  // Use supplied preset if possible.
  if(isset($presets[$presetname])) {
    return $presetname;
  }
  // First fallback, use a preset based on the target.
  // This avoids creating unnecessary presets.
  if (isset($presets[$target])) {
    $presetname = $target;
  }
  else {
    // Second callback, use the supplied preset name (e.g. an old deleted preset)
    // or failing that, the target.
    $presetname = empty($presetname) ? $target : $presetname;
    $preset = array('presetname' => $presetname);
    drupal_write_record('imagecache_preset', $preset);
    $action = array(
      'presetid' => $preset['presetid'],
      'weight' => 0,
      'module' => 'imagecache',
      'action' => 'imagecache_scale',
      'data' => array(
        'width' => '150',
        'height' => '150',
        'upscale' => 0));
    drupal_write_record('imagecache_action', $action);
    // Flush preset cache.
    imagecache_presets(TRUE);
  }
  // Update the settings to reflect the (potentially) new preset.
  $settings = _userphotos_settings($target);
  $settings['preset'] = $presetname;
  variable_set('userphotos_'. $target, $settings);
  return $presetname;
}

?>
eugenmayer’s picture

Category: bug » feature
Status: Closed (fixed) » Needs work

Well Alan, i will not find the time to look into this right now, especially as we have a feature-freeze for 6--1-0 anyway due the release canditate.
Anyway i reopen this as a feature request, any patches and especially tests are much appriated.

Thanks for the investigation Alan

eugenmayer’s picture

Status: Needs work » Closed (won't fix)

Well marking as wontfix. Creating a preset at minimum is a installation-step now. You can select presets you want to use since 1.3 in addition.