aboutsummaryrefslogtreecommitdiff
path: root/imagecache_auto.module
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2011-04-20 11:31:44 -0300
committerSilvio Rhatto <rhatto@riseup.net>2011-04-20 11:31:44 -0300
commitf96b2aa63aa09619dcd0a17c965b4435ef3f0692 (patch)
treeab6c31a1e6177edc390dd7c510bc68533def9f71 /imagecache_auto.module
parentf853375cba68a214937b634e56affa067a5f0d62 (diff)
downloadimagecache_auto-f96b2aa63aa09619dcd0a17c965b4435ef3f0692.tar.gz
imagecache_auto-f96b2aa63aa09619dcd0a17c965b4435ef3f0692.tar.bz2
Renaming module, adding README and LICENSE
Diffstat (limited to 'imagecache_auto.module')
-rw-r--r--imagecache_auto.module49
1 files changed, 49 insertions, 0 deletions
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 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Imagecache Auto.
+ *
+ * Creates imagecache presets on the fly.
+ */
+
+/**
+ * Implements hook_menu();
+ */
+function imagecache_auto_menu() {
+ $items = array();
+
+ $items[file_directory_path() .'/imagecache_auto'] = array(
+ 'page callback' => '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);
+}