I have a slideshow module that was using imagecache to ensure images were of specific height and width.
One problem I ran into was when making my module portable to another site, I was relying on a certain preset name to exist, so since module_exists() only got me half way to deciding if an image already had an existing preset to use, I added this little helper method to boolean check for a preset name.

Attached is the patch. I patched it to the DRUPAL-5 branch. Hope that was right.

CommentFileSizeAuthor
imagecache-add-preset-check.patch834 bytesemackn

Comments

emackn’s picture

oh.. forgot an example of how I was going to use this.

    if(module_exists("imagecache") && imagecache_preset_exists("slideshow")) {
      $_url = url("files/imagecache/slideshow/".$node->field_slideshow_image[0]['filepath'],NULL,NULL,TRUE);
    }
    else {
      $_url = url($node->field_slideshow_image[0]['filepath'],NULL,NULL,TRUE); 
    }
dopry’s picture

Status: Needs review » Fixed

This has been added to 2.x.. you can do if (imagecache_preset_by_name($presetname)) {} The load functions are also exists functions. The same may be true of 1.x I'm just not gonna dig into it.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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