/** * add_new * @param $data * @param string $image_arg the input[type=file][name] * OR * @param resource $image_arg the image resource */ public static function add_new_image($data, $image_arg) { if (!$image_arg) { throw new Exception("Image parameter is empty"); } static::db()->StartTrans(); $image = parent::add_new($data); if ($image) { $image_gd = self::get_gd($image_arg); if (!$image->save_gd($image_gd)) { static::db()->FailTrans(); } } else { throw new e_developer("Failed to insert image " . print_r($data, true)); } static::db()->CompleteTrans(); return $image; }