Dijital Ürün ve 2. el Ürün Satış Platformu / Şimdi Kayıt Ol

Sesli dinle

Seditio Attach Eklentisi ile Yüklediğiniz Resimleri Otomatik Boyutlandırma Yapacağız.

Bu Özellik Sadece Seditio 120+ ve 177'ye kadar olan sürümlerde geçerli.

Öncelikle Attach eklentisini buradan indiriyoruz.

Daha sonra attach/inc/function.php yi açıyoruz.

Alttakini buluyoruz. function att_add

function att_add($type, $item_id, $parent_id, $var_name, $title)
{
	global $cfg, $usr, $db_attach;
	if(!sed_auth('plug', 'attach', 'W')) return $L['att_err_perms'];
	$extp = @strrpos($_FILES[$var_name]['name'], '.') + 1;
	$ext = strtolower(@substr($_FILES[$var_name]['name'], $extp, strlen($_FILES[$var_name]['name']) - $extp));
	if(!($err = att_upload_err($var_name, $ext)))
	{
		// This is done in 2 steps, otherwise we may run into race condition
		$title = att_filter($title);
		$img = (int) in_array($ext, array('gif', 'jpg', 'jpeg', 'png'));
		sed_sql_query("INSERT INTO $db_attach (att_user, att_type, att_parent, att_item, att_path, att_ext, att_img, att_size, att_title, att_count)
		VALUES ({$usr['id']}, '$type', $parent_id, $item_id, '', '$ext', $img, {$_FILES[$var_name]['size']}, '$title', 0)");
		if(sed_sql_affectedrows() == 1)
		{
			$id = sed_sql_insertid();
			$tar = preg_match('#\.tar\.(gz|bz2)#i', $_FILES[$var_name]['name']) ? '.tar' : '';
			if($cfg['plugin']['attach']['userdir'])
			{
				$path = $cfg['plugin']['attach']['folder'].'/'.$usr['id'];
				if(!file_exists($path)) mkdir($path);
				$path .= '/'.$cfg['plugin']['attach']['prefix'].$id.$tar.'.'.$ext;
			}
			else $path = $cfg['plugin']['attach']['folder'].'/'.$cfg['plugin']['attach']['prefix'].$id.$tar.'.'.$ext;
			move_uploaded_file($_FILES[$var_name]['tmp_name'], $path);
			sed_sql_query("UPDATE $db_attach SET att_path = '$path' WHERE att_id = $id");
			if($img)
			{
				if(!att_create_thumb($path))
				{
					// XSS protect
					sed_sql_query("DELETE FROM $db_attach WHERE att_id = $id");
					@unlink($path);
					$err = 'thumb';
				}
			}
		}
		else $err = 'db';
	}
	else return $err;
}

Alttaki ile değiştiriyoruz.

function att_add($type, $item_id, $parent_id, $var_name, $title)
{
	global $cfg, $usr, $db_attach;
	if(!sed_auth('plug', 'attach', 'W')) return $L['att_err_perms'];
	$extp = @strrpos($_FILES[$var_name]['name'], '.') + 1;
	$ext = strtolower(@substr($_FILES[$var_name]['name'], $extp, strlen($_FILES[$var_name]['name']) - $extp));
	if(!($err = att_upload_err($var_name, $ext)))
	{
		// This is done in 2 steps, otherwise we may run into race condition
		$title = att_filter($title);
		$img = (int) in_array($ext, array('gif', 'jpg', 'jpeg', 'png'));
		sed_sql_query("INSERT INTO $db_attach (att_user, att_type, att_item, att_path, att_ext, att_img, att_size, att_title, att_count)
		VALUES ({$usr['id']}, '$type', $item_id, '', '$ext', $img, {$_FILES[$var_name]['size']}, '$title', 0)");
		if(sed_sql_affectedrows() == 1)
		{
			$id = sed_sql_insertid();
			$tar = preg_match('#\.tar\.(gz|bz2)#i', $_FILES[$var_name]['name']) ? '.tar' : '';
			if($cfg['plugin']['attach']['userdir'])
			{
				$path = $cfg['plugin']['attach']['folder'].'/'.$usr['id'];
				if(!file_exists($path)) mkdir($path);
				$path .= '/'.$cfg['plugin']['attach']['prefix'].$id.$tar.'.'.$ext;
			}
			else $path = $cfg['plugin']['attach']['folder'].'/'.$cfg['plugin']['attach']['prefix'].$id.$tar.'.'.$ext;
			//move_uploaded_file($_FILES[$var_name]['tmp_name'], $path);
			$tmp_name = $_FILES[$var_name]['tmp_name'];
			$resized_image = sed_image_resize($tmp_name, $path, '800', $ext, '90');
			move_uploaded_file($resized_image, $path);
			sed_sql_query("UPDATE $db_attach SET att_path = '$path' WHERE att_id = $id");
			if($img)
			{
				if($cfg['plugin']['attach']['thumbs'] == 1)
		{
				if(!att_create_thumb($path))
				{
					// XSS protect
					sed_sql_query("DELETE FROM $db_attach WHERE att_id = $id");
					@unlink($path);
					$err = 'thumb';
				}
		}
			}
		}
		else $err = 'db';
	}
	else return $err;
}

Yine aynı dosyada Alttakini buluyoruz. function att_update

function att_update($id, $var_name, $title = '')
{
	global $cfg, $usr, $db_attach;
	$title = att_filter($title);
	$extp = @strrpos($_FILES[$var_name]['name'], '.') + 1;
	$ext = strtolower(@substr($_FILES[$var_name]['name'], $extp, strlen($_FILES[$var_name]['name']) - $extp));
	if(!($err = att_upload_err($var_name, $ext)))
	{
		$sql = sed_sql_query("SELECT att_path, att_user FROM $db_attach WHERE att_id = $id");
		$row = sed_sql_fetcharray($sql);
		if($row['att_user'] != $usr['id'] && !sed_auth('plug', 'attach', 'A')) return $L['att_err_perms'];
		$path = $row['att_path'];
		@unlink($path);
		att_remove_thumb($path);
		$tar = preg_match('#\.tar\.(gz|bz2)#i', $_FILES[$var_name]['name']) ? '.tar' : '';
		if($cfg['plugin']['attach']['userdir'])
		{
			$path = $cfg['plugin']['attach']['folder'].'/'.$row['att_user'];
			if(!file_exists($path)) mkdir($path);
			$path .= '/'.$cfg['plugin']['attach']['prefix'].$id.$tar.'.'.$ext;
		}
		else $path = $cfg['plugin']['attach']['folder'].'/'.$cfg['plugin']['attach']['prefix'].$id.$tar.'.'.$ext;
		move_uploaded_file($_FILES[$var_name]['tmp_name'], $path);
		$size = filesize($path);
		$img = (int) in_array($ext, array('gif', 'jpg', 'jpeg', 'png'));
		$ttl = (empty($title)) ? '' : ", att_title = '$title'";
		sed_sql_query("UPDATE $db_attach SET att_ext = '$ext', att_img = $img, att_size = $size, att_path = '$path'$ttl WHERE att_id = $id");
		if(sed_sql_errno() > 0)
			$err = $L['att_err_db'].': '.sed_sql_error();
		if($img)
		{
			if(!att_create_thumb($path)) $err = 'thumb';
		}
	}
	elseif(!empty($title))
	{
		sed_sql_query("UPDATE $db_attach SET att_title = '$title' WHERE att_id = $id");
		if(sed_sql_affectedrows() != 1)
			$err = 'db';
	}
	return $err;
}

Alttaki ile değiştiriyoruz.

function att_update($id, $var_name, $title = '')
{
	global $cfg, $usr, $db_attach;
	$title = att_filter($title);
	$extp = @strrpos($_FILES[$var_name]['name'], '.') + 1;
	$ext = strtolower(@substr($_FILES[$var_name]['name'], $extp, strlen($_FILES[$var_name]['name']) - $extp));
	if(!($err = att_upload_err($var_name, $ext)))
	{
		$sql = sed_sql_query("SELECT att_path, att_user FROM $db_attach WHERE att_id = $id");
		$row = sed_sql_fetcharray($sql);
		if($row['att_user'] != $usr['id'] && !sed_auth('plug', 'attach', 'A')) return $L['att_err_perms'];
		$path = $row['att_path'];
		@unlink($path);
		att_remove_thumb($path);
		$tar = preg_match('#\.tar\.(gz|bz2)#i', $_FILES[$var_name]['name']) ? '.tar' : '';
		if($cfg['plugin']['attach']['userdir'])
		{
			$path = $cfg['plugin']['attach']['folder'].'/'.$row['att_user'];
			if(!file_exists($path)) mkdir($path);
			$path .= '/'.$cfg['plugin']['attach']['prefix'].$id.$tar.'.'.$ext;
		}
		else $path = $cfg['plugin']['attach']['folder'].'/'.$cfg['plugin']['attach']['prefix'].$id.$tar.'.'.$ext;
		//move_uploaded_file($_FILES[$var_name]['tmp_name'], $path);
		$tmp_name = $_FILES[$var_name]['tmp_name'];
			$resized_image = sed_image_resize($tmp_name, $path, '800', $ext, '90');
			move_uploaded_file($resized_image, $path);
		//move_uploaded_file(sed_image_resize($_FILES[$var_name]['tmp_name'], $path, '800', $ext, '90'));
		$size = filesize($path);
		$img = (int) in_array($ext, array('gif', 'jpg', 'jpeg', 'png'));
		$ttl = (empty($title)) ? '' : ", att_title = '$title'";
		sed_sql_query("UPDATE $db_attach SET att_ext = '$ext', att_img = $img, att_size = $size, att_path = '$path'$ttl WHERE att_id = $id");
		if(sed_sql_errno() > 0)
			$err = $L['att_err_db'].': '.sed_sql_error();
		if($img)
		{
			if($cfg['plugin']['attach']['thumbs'] == 1)
		{
			if(!att_create_thumb($path)) $err = 'thumb';
		}
		}
	}
	elseif(!empty($title))
	{
		sed_sql_query("UPDATE $db_attach SET att_title = '$title' WHERE att_id = $id");
		if(sed_sql_affectedrows() != 1)
			$err = 'db';
	}
	return $err;
}

Daha sonra yine aynı dosyada en alta alttakini ekleyin.

function sed_image_resize($img_big, $img_small, $small_x, $extension, $jpegquality)
{
	if (!function_exists('gd_info')) {
		return;
	}
	global $cfg;
	switch ($extension) {
		case 'gif':
			$source = imagecreatefromgif($img_big);
			break;
		case 'png':
			$source = imagecreatefrompng($img_big);
			break;
		default:
			$source = imagecreatefromjpeg($img_big);
			break;
	}
	$big_x = imagesx($source);
	$big_y = imagesy($source);
	$thumb_x = $small_x;
	$thumb_y = floor($big_y * ($small_x / $big_x));
	if ($cfg['th_amode'] == 'GD1') {
		$new = imagecreate($thumb_x, $thumb_y);
	} else {
		$new = imagecreatetruecolor($thumb_x, $thumb_y);
	}
	imagealphablending($new, false); //Set the blending mode for an image
	imagesavealpha($new, true); //Set the flag to save full alpha channel information
	if ($cfg['th_amode'] == 'GD1') {
		imagecopyresized($new, $source, 0, 0, 0, 0, $thumb_x, $thumb_y, $big_x, $big_y);
	} else {
		imagecopyresampled($new, $source, 0, 0, 0, 0, $thumb_x, $thumb_y, $big_x, $big_y);
	}
	switch ($extension) {
		case 'gif':
			imagegif($new, $img_small);
			break;
		case 'png':
			imagepng($new, $img_small);
			break;
		default:
			imagejpeg($new, $img_small, $jpegquality);
			break;
	}
	imagedestroy($new);
	imagedestroy($source);
	return;
}

Otomatik olarak Genişlik 800 değerini alacaktır, genişliğe oranla yükleklikte otomatik ayarlanacaktır.


Yorumlar (0)
henüz yorum yok
Tema Ayarları

Kendi özelleştirilmiş stilini belirle

Mod Seç

Uygulamanız için mükemmel renk modunu seçin.


RTL Mode

Dil yönünüzü değiştirin


Fluid Layout

Tam ekran modu aç/kapat


Navigasyon Konumu

Web sitesi için uygun bir menü sistemi seçin


Görünüm