Since Imagecache Presets can be defined in code, storing the numeric ID is fairly volatile (if a preset stored in code is overriden, it gets a new numeric ID, which the imagecache profiles module doesn't pick up). The attached patch switches the module to store the preset name instead, which is constant across a preset stored in code, and then overridden. The patch also adds an update hook for updating this on existing sites.

CommentFileSizeAuthor
#1 imagecache_profiles.presetname.patch2.01 KBjhedstrom

Comments

jhedstrom’s picture

StatusFileSize
new2.01 KB

And the patch.

andypost’s picture

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

What do you mean by "can be defined in code"? What code can define preset? Take a look at #349331: Views 2 Support in 6.x + optimizations

jhedstrom’s picture

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

Imagecache presets, like views, panels and other exportables, can be defined by a module, using hook_imagecache_default_presets() (#255421: Patch for imagecache preset exporting). When one of these presets is set as one of the profile images, if that preset is then overridden, this module doesn't pick up the change, and in fact reverts to using no presets at all. This patch resolves that by using the preset name, which is unique, but more permanent than the imagecache preset ID.

andypost’s picture

Status: Needs review » Needs work

So it needs work to catch this update and change ID to new. I see no reason to store reset name which could be changed more often

jhedstrom’s picture

Imagecache itself uses the preset name rather than the numeric ID. Take a look at imagecache_field_formatter_info() and imagecache_theme() functions. Because of this, the Views module, and any other module that uses CCK formatters for displaying data is storing the preset name.

andypost’s picture

Status: Needs work » Needs review

I see no valuable reason to store preset name because if any contrib would try to use hook_imagecache_default_presets() then it should assign this preset to ICP variable and at this stage it's not a problem to get current ID of provided preset name.

ICP works at _preprocess stage so it's MORE OFTEN preset name could be changed against imported.

ICP should follow more common using... which is manually choosing a preset

amitaibu’s picture

Features module also exportes imagecache by *name* e.g:

/**
 * Helper to implementation of hook_imagecache_default_presets().
 */
function _razoss_imagecache_default_presets() {
  $items = array(
    'user_image_default_SC100X100' => array(
      'presetname' => 'user_image_default_SC100X100',
      'actions' => array( 
     // ....
    ),
andypost’s picture

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

As I said before - Preset name and variable value is different.

You could export presets and then you should configure variables, at this stage you should convert preset-name into real ID which stored in DB and variable

yhahn’s picture