4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: stomi on May 19, 2003, 11:55:26 AM

Title: Simplifying Image Upload
Post by: stomi on May 19, 2003, 11:55:26 AM
Hi all.

I want to simplify the image upload for users.

The existing process looks like this:

First I browse the harddisk for an image file:

(http://nbc.wakeforum.de/data/media/3/screen1.jpg)

Then I have to choose a file-name.

I removed the thumbnail fields, because I use auto-thumbnailing.

Then i click submit and after a successful upload the following screen comes up:
(http://nbc.wakeforum.de/data/media/3/screen2.jpg)

---------------------------------------------

Now I got 2 requests:

At first, i don't want that "Image Name" is a mandatory field.
If the user decides to leave the "Image Name" field empty, the file name should be the Image name automatically.

Is this possible?


Second one: After successfully uploading an image, the image shouldn't be displayed. A short success message would be enough. The Image upload fields should be up again, so that the user can quickly upload another image.


Are there already mods doing that?
Is it much effort?

Help is appreciated.
Thanks, K.
Title: Simplifying Image Upload
Post by: V@no on May 20, 2003, 06:17:51 AM
Quote from: stomi
Are there already mods doing that?
Is it much effort?
No ;)
Here is a quick fix for that ;)

open /member.php
find:
Code: [Select]
 if ($image_name == "")  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['image_name']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }
comment it or simply remove it ;)
then find:
Code: [Select]
$current_time = time();add after:
Code: [Select]
if (!$image_name)
{
  $image_name = $HTTP_POST_VARS['image_name'] = get_file_name($new_name);
}
now, image name entry is not necerry, it will use filename (without extention) if its empty.


to fix the "after upload" page, just find:
Code: [Select]
$content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n".$media."\n</td>\n</tr>\n</table>\n";add after:
Code: [Select]
$action = "uploadform";
that's all.
but if u'd like it remmber the fields (image name, keywords, description)
also add:
Code: [Select]
$sendprocess = 1;
good luck ;)
Title: Simplifying Image Upload
Post by: stomi on May 20, 2003, 10:10:33 AM
yeah.. that works great.

10000000 thanks @ v@no.


now picture upload is very fast and comfortable
Title: Simplifying Image Upload
Post by: Slammer on June 20, 2003, 01:48:06 PM
a little question about this one, V@no you said:
Quote
open /member.php
find:Code:
  if ($image_name == "")  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['image_name']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }

comment it or simply remove it


i my member.php there are two of these codes, does this mean i delete both of them?
thnx.
Title: Simplifying Image Upload
Post by: V@no on June 20, 2003, 02:31:39 PM
I dont know, because I have just one, default 4images has just one part with that code. its in if ($action == "uploadimage") {...} part (just scroll up a little bit to see what $action is being execute.
Title: Re: Simplifying Image Upload
Post by: Xmode on June 08, 2005, 05:47:25 AM
hey vano it doesnt work for me is there anyway i can download your member.php ? thx
Title: Re: Simplifying Image Upload
Post by: V@no on June 08, 2005, 06:06:29 AM
hey vano it doesnt work for me
sorry to hear that.

is there anyway i can download your member.php ?
U could, but I dont think u want it. I'm 102% sure it will not work for u at all ;)
Title: Re: Simplifying Image Upload
Post by: Xmode on June 08, 2005, 06:33:10 AM
why it will not work ?? is there other way ? :cry:
Title: Re: Simplifying Image Upload
Post by: Acidgod on November 28, 2005, 01:22:28 PM
why it will not work ??

Look at V@nos Site and you will see that he has many modifications on his Site and in the member.php...
And thats the way why his member.php dont work with your Gallery... (o:
Title: Re: Simplifying Image Upload
Post by: bxmas13 on December 12, 2005, 08:44:43 PM
Quote
why it will not work ?? is there other way ?

Xmode:  I made the same mistake and couldn't figure out why the changes wouldn't work.  Until I looked closer.

When you search for this:
Code: [Select]
  if ($image_name == "")  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['image_name']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }

Make sure it is 39 lines below this code:

Code: [Select]
if ($action == "uploadimage") {

Make sure you DO NOT comment the code below this:
Code: [Select]
if ($action == "updateimage") {
Once you make those changes it will work!  :wink:
Title: Re: Simplifying Image Upload
Post by: V@no on December 25, 2005, 11:19:05 AM
I just found a bug with this method, the keywords not being populated...
To fix that, in member.php instead of
Code: [Select]
$image_name = ($image_name) ? $image_name : get_file_name($new_name);use:
Code: [Select]
if (!$image_name)
{
  $image_name = $HTTP_POST_VARS['image_name'] = get_file_name($new_name);
}

P.S. I've updated my original post.
Title: Re: Simplifying Image Upload
Post by: himu on January 26, 2006, 09:13:07 AM
I dont know, because I have just one, default 4images has just one part with that code. its in if ($action == "uploadimage") {...} part (just scroll up a little bit to see what $action is being execute.

Interestingly i have the same issue.. follwing are the two instances of if ($action == "uploadimage") {...} if ($image_name == ""){...} part:  :roll: (I have commented them both and it seems to be working.)

Line 329 - 359
Code: [Select]
if ($action == "updateimage") {
  if (!$image_id || ($config['user_edit_image'] != 1 && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
  }
  $sql = "SELECT image_id, cat_id, user_id, image_name
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
  $image_row = $site_db->query_firstrow($sql);
  if (!$image_row || $image_row['user_id'] <= USER_AWAITING || ($user_info['user_id'] != $image_row['user_id'] && $user_info['user_level'] != ADMIN)) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = get_category_path($image_row['cat_id'], 1).$config['category_separator']."<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_id)."\" class=\"clickstream\">".$image_row['image_name']."</a>".$config['category_separator'];
  $txt_clickstream .= $lang['image_edit'];

  $error = 0;

  $image_preview = (isset($HTTP_POST_VARS['image_preview'])) ? 1 : 0;
  $image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name']));
  $image_description = un_htmlspecialchars(trim($HTTP_POST_VARS['image_description']));
  $image_keywords = un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords']));
  $image_keywords = preg_replace("/[\n\r]/is", " ", $image_keywords);
  $image_keywords = str_replace(","," ",$image_keywords);
  $image_keywords = ereg_replace("( ){2,}", " ", $image_keywords);

//  if ($image_name == "")  {
//    $error = 1;
//    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['image_name']), $lang['field_required']);
//    $msg .= (($msg != "") ? "<br />" : "").$field_error;
//  }

Line 491 - 537
Code: [Select]
if ($action == "uploadimage") {
  if ($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_permission("auth_upload", $cat_id))) {
    show_error_page($lang['no_permission']);
    exit;
  }

  $txt_clickstream = "";
  if ($cat_id && isset($cat_cache[$cat_id])) {
    $txt_clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
  }
  $txt_clickstream .= $lang['user_upload'];

  $remote_media_file = format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['remote_media_file'])));
  $remote_thumb_file = format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['remote_thumb_file'])));

  $image_preview = (isset($HTTP_POST_VARS['image_preview'])) ? 1 : 0;
  $image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name']));
  $image_description = un_htmlspecialchars(trim($HTTP_POST_VARS['image_description']));
  $image_keywords = un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords']));
  $image_keywords = preg_replace("/[\n\r]/is", " ", $image_keywords);
  $image_keywords = str_replace(","," ",$image_keywords);
  $image_keywords = ereg_replace("( ){2,}", " ", $image_keywords);

  $image_active = (isset($HTTP_POST_VARS['image_active']) && $HTTP_POST_VARS['image_active'] == 0) ? 0 : 1;
  $image_allow_comments = (isset($HTTP_POST_VARS['image_allow_comments']) && $HTTP_POST_VARS['image_allow_comments'] == 0) ? 0 : 1;
  $image_download_url = (isset($HTTP_POST_VARS['image_download_url'])) ? format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['image_download_url']))) : "";

  $direct_upload = (check_permission("auth_directupload", $cat_id)) ? 1 : 0;
  $upload_cat = ($direct_upload) ? $cat_id : 0;

  $error = 0;
  $uploaderror = 0;

  if ($cat_id == 0)  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['category']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }
  if ((empty($HTTP_POST_FILES['media_file']['tmp_name']) || $HTTP_POST_FILES['media_file']['tmp_name'] == "none") && ($remote_media_file == "" || !check_remote_media($remote_media_file))) {
    $error = 1;
    $msg .= (($msg != "") ? "<br />" : "").$lang['image_file_required'];
  }
//  if ($image_name == "")  {
//    $error = 1;
//    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['image_name']), $lang['field_required']);
//    $msg .= (($msg != "") ? "<br />" : "").$field_error;
//  }

any clues?

2nd question:
How can i replace the (_) underscores of file name to ( ) spaces in the Image Name?
Title: Re: Simplifying Image Upload
Post by: V@no on January 26, 2006, 02:49:29 PM
any clues?
The first instance is for edit images, you should leave it intact, but the second instanse is what you are looking for.

2nd question:
How can i replace the (_) underscores of file name to ( ) spaces in the Image Name?
replace
Code: [Select]
  $image_name = $HTTP_POST_VARS['image_name'] = get_file_name($new_name);with:
Code: [Select]
  $image_name = $HTTP_POST_VARS['image_name'] = str_replace("_", " ", str_replace("%20", " ", get_file_name($new_name)));
Title: Re: Simplifying Image Upload
Post by: himu on January 26, 2006, 04:38:42 PM
Awesome... Thanks! V@no... u the man.
Title: Re: Simplifying Image Upload
Post by: spiritwolf2000 on March 26, 2006, 05:43:01 AM
I have this code in my member.php file:

Code: [Select]
      $content .= "<table border=\"0\" align=\"center\">\n<tr>\n<td>\n".$media."\n</td>\n</tr>\n</table>\n";
    }
    else {
      $action = "uploadform";
      $sendprocess = 1;
    }
  }
  else {
    $action = "uploadform";
    $sendprocess = 1;
  }
}

But its not working.  This is straight from the original member.php file with 1.7.2...  But yet on my other site with the same code it is working?!?  Any suggestions would be appreciated!  It was working before applying the update.
Title: Re: Simplifying Image Upload
Post by: dbranko on November 03, 2006, 12:11:15 AM
It's working!!! :D :D :D :D :D :D :D :D

Thanks Vano and friends!!!
Title: Re: Simplifying Image Upload
Post by: Sleepy on May 20, 2011, 07:01:43 AM
This is exactly the MOD I need, thanks.
However, is it compatible with 1.7.10?

I just upgraded to 1.7.10 and modified the file to apply this MOD.
However, the system still ask me to input the image name.
Does anyone know what the problem might be?

Thank you very much.
Title: Re: Simplifying Image Upload
Post by: MrAndrew on August 07, 2011, 08:14:52 PM
Few another question....

If i change this path in member.php

$file = (is_remote($new_name)) ? $new_name : (($direct_upload) ? MEDIA_PATH."/".$cat_id."/".$new_name : MEDIA_TEMP_PATH."/".$new_name);

On

$file = (is_remote($new_name)) ? $new_name : (($direct_upload) ? THUMB_PATH."/".$cat_id."/".$new_name : THUMB_TEMP_PATH."/".$new_name);

It will show me thumbnail... But how can i apply a link to big photo for thumbnail? (By click on thumbnail, open direct link to photo)

Many thanks!
Title: Re: Simplifying Image Upload
Post by: partymunich.de on March 18, 2012, 03:08:44 AM
Hello,

instead of using the file name as a image name in my gallery, i would like the Mod to be adding the category name with a number at the end.

e.g: Category name: "Test"
When uploading image #1 the name should be "Test 001", #2 should be "Test 002" and so on.

Is there an easy way to implement this Mod?

Thank you very much in advance!

Greetings!