4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Dandily on June 28, 2005, 07:03:13 PM
-
Hello everybody!
When i upload image in 4im, it saves on site with original file name. How can i do that images names will be IMAGE_ID.jpg?
I`m not very good in 4im structure, so it`ll take a lot of time to me to find where to make changes. I think thats not a big problem for old users of 4im. So i ask if anybody can help me in that :)
Thanks a lot.
-
this question was asked before, and no real solution was provided.
The reason is that image file being saved before the new image being added into the database, so the image id is not avalable when image being renamed (if needed) and saved to the correct path.
Other words, u'll need to rename the media file and thumbnail and then update the database with new filename.
-
ok, here is a beginning, it works only for "direct upload" images (without validation)
in member.php find: if ($config['upload_notify'] == 1 && !$direct_upload) {
Insert above: if ($direct_upload) {
function _rename($old, $new){
$cwd = getcwd();
chdir(realpath(dirname($old)));
$ok = (rename(basename($old), basename($new))) ? 1 : 0;
chdir($cwd);
return $ok;
}
$media_path = MEDIA_PATH."/".$cat_id."/";
$thumb_path = THUMB_PATH."/".$cat_id."/";
$media_ext = strtolower(substr(strrchr($new_name,"."), 1));
$thumb_ext = strtolower(substr(strrchr($new_thumb_name,"."), 1));
$new_media = (_rename($media_path.$new_name, $media_path.$image_id.".".$media_ext)) ? $image_id.".".$media_ext : $new_name;
$new_thumb = (!empty($new_thumb_name) && _rename($thumb_path.$new_thumb_name, $thumb_path.$image_id.".".$thumb_ext)) ? $image_id.".".$thumb_ext : $new_thumb_name;
$sql = "UPDATE ".IMAGES_TABLE."
SET image_media_file = '$new_media', image_thumb_file = '$new_thumb'
WHERE image_id = $image_id";
$site_db->query($sql);
}
Tested on v1.7.1
-
Thanks a lot, it works fine!
-
Vano hello, in version 1.7.6 does not work.
tks
-
Doesn't work how?
-
in 1.7.6 works fine!
Thanks again V@no)
Вся Россия тебе благодарна ;)