From f96b2aa63aa09619dcd0a17c965b4435ef3f0692 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 20 Apr 2011 11:31:44 -0300 Subject: Renaming module, adding README and LICENSE --- imagecache_auto.module | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 imagecache_auto.module (limited to 'imagecache_auto.module') diff --git a/imagecache_auto.module b/imagecache_auto.module new file mode 100644 index 0000000..22e077f --- /dev/null +++ b/imagecache_auto.module @@ -0,0 +1,49 @@ + 'imagecache_auto', + 'access callback' => TRUE, + 'type' => MENU_CALLBACK + ); + + return $items; +} + +/** + * Automatically create imagecache presets. + * + * @todo + * Check if width and heigh are integers. + * Specify maximum and minimum dimensions. + */ +function imagecache_auto() { + include_once('imagecache_auto.inc'); + + $args = func_get_args(); + $options = array( + 'width' => check_plain(array_shift($args)), + 'height' => check_plain(array_shift($args)), + 'path' => implode('/', $args), + ); + + // Make sure that the preset exists. + imagecache_auto_create_preset($options); + + // Redirect to the image cache image version. + $path = file_directory_path() .'/imagecache/'. $options['width'] .'x'. $options['height'] .'/'. $options['path']; + drupal_goto($path); +} -- cgit v1.2.3