Skip to content

Commit

Permalink
modified to populate thumbnail_image_type and original_image_type - a…
Browse files Browse the repository at this point in the history
…lso added constructor logic to reduce max_upload_number if php value max_file_uploads sets a smaller limit
  • Loading branch information
natepixel committed Mar 13, 2012
1 parent fec37fb commit 7572bd1
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions reason_4.0/lib/core/classes/image_import.php
Expand Up @@ -71,6 +71,25 @@ class PhotoUploadForm extends disco
var $user_id;
var $categories;
var $max_upload_number = 25;
/**
* Converting from type to extension
*/
var $image_types = array(1=>'gif',2=>'jpg',3=>'png');

/**
* If max_upload_number exceeds php's setting, lets reduce it dynamically.
*/
function __construct()
{
$max_file_uploads = ini_get('max_file_uploads');
if (!empty($max_file_uploads) && is_numeric($max_file_uploads))
{
if ($max_file_uploads < $this->max_upload_number)
{
$this->max_upload_number = $max_file_uploads;
}
}
}

function get_available_categories($site_id)
{
Expand Down Expand Up @@ -382,6 +401,12 @@ function process()
$new_name = PHOTOSTOCK.$id.'.'.$type;
$orig_name = PHOTOSTOCK.$id.'_orig.'.$type;
$tn_name = PHOTOSTOCK.$id.'_tn.'.$type;

// Support for new fields; they should be set null by default, but will be
// changed below if a thumbnail/original image is created. This is very messy...
$thumbnail_image_type = null;
$original_image_type = null;

// atomic move the file if possible, copy if necessary
if( is_writable( $cur_name ) )
{
Expand All @@ -407,6 +432,7 @@ function process()
{
copy( $new_name, $tn_name );
resize_image($tn_name, $thumb_dimensions['width'], $thumb_dimensions['height']);
$thumbnail_image_type = $this->image_types[$type];
}

// real original
Expand All @@ -422,6 +448,7 @@ function process()
{
copy( $my_orig_name, $orig_name);
}
$original_image_type = $this->image_types[$type];
}

$info = getimagesize( $new_name );
Expand All @@ -432,6 +459,8 @@ function process()
'width' => $info[0],
'height' => $info[1],
'size' => $size,
'thumbnail_image_type' => $thumbnail_image_type,
'original_image_type' => $original_image_type
);

// update with new info - don't archive since this is really just an extension of the creation of the item
Expand Down

0 comments on commit 7572bd1

Please sign in to comment.