|
5 | 5 | class ImageUtils {
|
6 | 6 |
|
7 | 7 | /**
|
8 |
| - * Creates a thumbnail image from the given image at the path. |
| 8 | + * Creates a thumbnail image from the given image at the path. (shorthand for createVariation) |
9 | 9 | * @param string $imagepath - path of original image
|
10 | 10 | * @param int $maxWidth - maximum new width
|
11 | 11 | * @param int $maxHeight - maximum new height
|
12 | 12 | * @param string $targetDir - target directory
|
13 | 13 | * @return string - the path of the new image file, e.g. /target/dir/basename.variation.png (or NULL in case of GD issues)
|
14 | 14 | */
|
15 | 15 | public static function createThumbnail($imagePath, $maxWidth, $maxHeight, $targetDir = NULL) {
|
| 16 | + return self::createVariation($imagePath, 'thumbnail', $maxWidth, $maxHeight, $targetDir); |
| 17 | + } |
| 18 | + |
| 19 | + /** |
| 20 | + * Creates a thumbnail image from the given image at the path. |
| 21 | + * @param string $imagepath - path of original image |
| 22 | + * @param string $variation - new variation name to be used |
| 23 | + * @param int $maxWidth - maximum new width |
| 24 | + * @param int $maxHeight - maximum new height |
| 25 | + * @param string $targetDir - target directory |
| 26 | + * @return string - the path of the new image file, e.g. /target/dir/basename.variation.png (or NULL in case of GD issues) |
| 27 | + */ |
| 28 | + public static function createVariation($imagePath, $variation, $maxWidth, $maxHeight, $targetDir = NULL) { |
16 | 29 | if (!file_exists($imagePath)) {
|
17 | 30 | $targetPath = NULL;
|
18 | 31 | } else {
|
19 |
| - $targetPath = self::getNewPath($imagePath, 'thumbnail', $targetDir); |
| 32 | + $targetPath = self::getNewPath($imagePath, $variation, $targetDir); |
20 | 33 | }
|
21 | 34 |
|
22 | 35 | if ($targetPath != NULL) {
|
|
0 commit comments