When using imagecache presets that are defined in code (e.g. as exportables), they do not have a preset id in the database and/or may have a different one than what the imagecache profile variables were saved as.

This patch allows imagecache presets to be referenced by name in the variables allowing them to, for example, be usable after export by Features and Strongarm. If the variable is numeric, will fall back to loading by preset id.

Patched against DRUPAL-6--1.

CommentFileSizeAuthor
imagecache_profiles_preset_by_name.patch2.38 KByhahn
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost’s picture

This is a duplicate of #654566: Store Imagecache preset name rather than numeric ID

Please re-open if this change is really needed I can rollback #349331: Views 2 Support in 6.x + optimizations to storing preset-name, but it require downgrade-path

yhahn’s picture

Status: Needs review » Active

Please read my comment and the patch itself. You will see that the Views patch does not need to be rolled back, nor would a downgrade/upgrade path be required as the patch allows you to refer to imagecache preset by either name or by preset ID. This will allow existing installs to continue using their current settings without problem.

I have read your comments in #654566: Store Imagecache preset name rather than numeric ID and while you are correct that imagecache presets that are stored in the database can have their preset name changed, this is not true of imagecache exported presets. Moreover, the design of imagecache implies the preset name is the canonical id of an imagecache preset, given that it is the actual reference point in the URL external to the Drupal system. In other words, if imagecache truly meant for the preset ID to be the primary identifier for an imagecache preset, you would use a URL like

http://my-site.com/sites/default/files/imagecache/1/foo.jpg

rather than

http://my-site.com/sites/default/files/imagecache/mypreset/foo.jpg

Given that changing the name of a preset also breaks all past URLs generated using it, it's neither an advisable operation nor an actually trivial "renaming."

andypost’s picture

I agree with you, but checking is_numeric($size) is not good because users can give a numeric names to there presets also is_int() doesn't work because form results return strings.

So we need to unify both settings to preset_name which is hard for existing views or hope that no one used numeric names for presets...

yhahn’s picture

I personally would go with the latter ("hope that no one used numeric names for presets") and see what kind of reports come back from users. I would consider this a reasonable limitation until you start a new branch of the project and can consolidate settings.

andypost’s picture

Status: Active » Needs review

So let's get reviews on that and #719632: Views 3 compability

Then I plan new release

andypost’s picture

Version: 6.x-1.x-dev » 6.x-1.2-rc1
Status: Needs review » Fixed

Commited into RC1

DamienMcKenna’s picture

Out of interest, would it be too much to request that Imagecache be changed to disallow numerical profile names?

andypost’s picture

Seems reasonable but now imagecache in core...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.