Welcome Guest, Not a member yet? Register   Sign In
Create thumbnail and output to browser - from a function - (avoid creating file)
#1

[eluser]CARP[/eluser]
Hi
I have a function that receives a parameter $file=path+filename and should return the image thumbnail of that file

Code:
function thumb($file){
$config['image_library'] = 'gd2';
$config['source_image']    = $file;
$config['create_thumb'] = FALSE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 200;
$config['height'] = 200;
$CI->load->library('image_lib', $config);
return $CI->image_lib->resize();
}

This function is called in a foreach loop from a view file.
The problem is that it is not returning anything, nor errors, but I guess it is because I should use the header function, right? But: how?

Thanks a lot in advance
#2

[eluser]d1a8lo24[/eluser]
See the following thread and look at the code i posted hope it helps you out
http://ellislab.com/forums/viewthread/188264/P15/
#3

[eluser]CARP[/eluser]
Hi d1a8lo24
I tried your code, but didn't work. It seems it need a file located in disk, but I need to create the thumbnail without saving it to disk, and return this thumbnail back to the view.

Thanks,
#4

[eluser]William Rufino[/eluser]
you have to echo the content of the image with the correct mime type...
#5

[eluser]CARP[/eluser]
[quote author="William Rufino" date="1305912042"]you have to echo the content of the image with the correct mime type...[/quote]


could you give me a hand->example? thanks




Theme © iAndrew 2016 - Forum software by © MyBB