summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filefield.devel.inc16
1 files changed, 15 insertions, 1 deletions
diff --git a/filefield.devel.inc b/filefield.devel.inc
index bd3ebf7..3cb0116 100644
--- a/filefield.devel.inc
+++ b/filefield.devel.inc
@@ -2,6 +2,12 @@
// $Id$
/**
+ * @file
+ * Utility functions for generating FileField content. Note that image
+ * generation support requires the GD toolkit.
+ */
+
+/**
* Private function used by filefield_content_generate().
*/
function _filefield_content_generate($node, $field) {
@@ -41,7 +47,7 @@ function _filefield_generate_file($field) {
$filesize = empty($field['widget']['max_filesize_per_file']) ? 1024 : parse_size($field['widget']['max_filesize_per_file']);
return _filefield_generate_textfile($filesize);
}
- elseif (in_array($extension, array('png', 'jpg'))) {
+ elseif (in_array($extension, array('png', 'jpg')) && function_exists('imagecreate')) {
$min_resolution = empty($field['widget']['min_resolution']) ? '100x100' : $field['widget']['min_resolution'];
$max_resolution = empty($field['widget']['max_resolution']) ? '600x600' : $field['widget']['max_resolution'];
return _filefield_generate_image($extension, $min_resolution, $max_resolution);
@@ -50,6 +56,9 @@ function _filefield_generate_file($field) {
return FALSE;
}
+/**
+ * Private function for generating a random text file.
+ */
function _filefield_generate_textfile($filesize = 1024) {
static $filesizes = array();
@@ -69,6 +78,11 @@ function _filefield_generate_textfile($filesize = 1024) {
return $temp_file;
}
+/**
+ * Private function for creating a random image.
+ *
+ * This function only works with the GD toolkit. ImageMagick is not supported.
+ */
function _filefield_generate_image($extension = 'png', $min_resolution, $max_resolution) {
static $images = array();