Welcome Guest, Not a member yet? Register   Sign In
Image_lib is quite inconvenient in its current state.
#1

[eluser]stevefink[/eluser]
Hi all,

First and foremost, I've had nothing short of a blast developing with Code Igniter, so please do not take this post in a derogatory way.

My current grief with the Image_lib library is that it does not give me a way to override the default naming schema for attached thumbnails through the API. Uploaded file foo.jpg will be named foo_thumb.jpg which makes it very inconvenient to locate without using any string type functions. (strpos, substr or regex)

As a temporary work around so I can continue working on this project, I edited Image_lib.php directly and changed the following:

old:

Code:
var $thumb_marker        = '_thumb';

new:

Code:
var $thumb_marker        = 'thumb_';

and the following:

old:

Code:
$this->full_dst_path = $this->dest_folder.$filename.$this->thumb_marker.$file_ext;
new:

Code:
$this->full_dst_path = $this->dest_folder.$this->thumb_marker.$filename.$file_ext;

I'm not an experienced developer by any means, so perhaps I'm overlooking something. Is there a reason it was created in the current fashion? By flipping those two switches around, I can now do something such as the following in my view:

Code:
<img src="&lt;?= base_url().thumb_$filename ?&gt;"

Thanks for taking a look at this.

- sf
#2

[eluser]Michael Wales[/eluser]
I just always store the filename in the database and then append _thumb to it to get the thumbnail.
#3

[eluser]stevefink[/eluser]
The other issue I was having is after creating thumbnails, my thumbnail comes out distorted .. that's probably an issue with my GD I'd imagine? Ever see something similar?

Original upload: http://stevefink.net/1.jpg
Thumbnail: http://stevefink.net/1_thumb.jpg

- sf
#4

[eluser]coolfactor[/eluser]
Image_lib is a library, so you can modify it without touching the built-in class. Just create a MY_Image_lib class that you keep in your application/libraries folder, and provide your own version of functions that you want to behave differently.

Personally, I'd store the name of the thumbnail in the database, rather than _assume_ that it always takes the form "thumb_$filename". That's a very restrictive way to approach things.

As for the distortion of your thumbnail, we'd need to see your code in order to zero in on the problem there.

Neither of those issues are about the Image library being inconvenient. Try to phrase your topic appropriately so others are more willing to respond to the thread.
#5

[eluser]Michael Wales[/eluser]
I remember seeing other topics concerning the horrible quality of GD thumbnails. Do some searching around - I am sure there is a fix or a bug report filed.
#6

[eluser]Crimp[/eluser]
The quality of GD is amazingly bad compared to GD2. Not only for thumbs. Run php info on your server and check which version is available. Set the GD2 in configs. I'd also echo the recommendation of simply storing filenames in the db. It's foolproof (hence perfect for me) and also allows for easy use of encryption to make direct access to files more difficult.




Theme © iAndrew 2016 - Forum software by © MyBB