Welcome Guest, Not a member yet? Register   Sign In
image_lib non-object?
#1

[eluser]SailorJohn[/eluser]
Having a problem with image manipulation.

From my test page, I'm getting this error:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Loader::$image_lib

Filename: views/test.php

Line Number: 19

...

Fatal error: Call to a member function resize() on a non-object ... on line 19

Here's the view:




<div style="width:300px; border:1px solid #000000; float:left;">
<img src="/images/loadingAnimation.gif">
<br><br>
&lt;?php

$config['image_library'] = 'gd2';
$config['source_image'] = '/images/loadingAnimation.gif';
$config['new_image'] = '/images/loadingAnimation_new.gif';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 50;

$this->load->library('image_lib', $config);

$this->image_lib->resize();


?&gt;
</div>

Line 19 is: $this->image_lib->resize();


The image <img src="/images/loadingAnimation.gif"> displays as it should. The directory has 777 permissions. I have gd2 loaded, per phpinfo().

Any clues? I'm kind of lost here.

Thanks!
#2

[eluser]Jelmer[/eluser]
Such code doesn't belong in the view. You should put it in the controller and there it will work as expected.

There's a way to make this work in the view but I would recommend you put it in the controller.

Also your question belongs in the "CodeIgniter Discussion" forum, the "Ignited Code" forum is meant for posting code you want to share with others - not support for general CI issues.
#3

[eluser]SailorJohn[/eluser]
Thanks for your suggestions.

I moved the code to the controller, corrected the path to the image (needed the full server path from root on a unix box) and it worked!

Thanks again.




Theme © iAndrew 2016 - Forum software by © MyBB