<?php

function gera_thumbnail($field ,$field_value, $folder, $path_thumb, $width, $height)
{
	
	if(isset($field) && isset($field_value) && isset($folder) && isset($path_thumb) && (isset($width) || isset($height)))
	{		
	    $CI =& get_instance();
	    $CI->load->library('easyphpthumbnail');
		
		$thumb = new easyphpthumbnail;
		
		$thumb->Thumblocation = $path_thumb;			
		if(isset($width))
		{
			$thumb->Thumbwidth = $width;
		}
		if(isset($height))
		{
			$thumb->Thumbheight = $height;
		}
		$thumb->Quality = 60;
		$thumb->Createthumb($folder.'/'.$field_value,'file');
	}
}


function get_file_thumbnail($field_value, $folder, $path_thumb, $width = null, $height = null)
{
	
	if(isset($field_value) && isset($folder) && isset($path_thumb) && (isset($width) || isset($height)))
	{		
	    $CI =& get_instance();
	    $CI->load->library('easyphpthumbnail');
		
		$thumb = new easyphpthumbnail;
		
		$thumb->Thumblocation = $path_thumb;			
		if($width??false)
		{
			$thumb->Thumbwidth = $width;
		}
		if($height??false)
		{
			$thumb->Thumbheight = $height;
		}
		$thumb->Quality = 60;
		$thumb->Createthumb($folder.'/'.$field_value,'file');
	}
}