blob: 22e077fed8f6200c165ada37f445fe26a54163c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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);
}
|