PHP image resizing/caching using phpThumb and mod_rewrite

Associate
Joined
29 Dec 2004
Posts
2,253
I have been reading this article as it looks like an excellent way of resizing images and caching them so that after the image has been cached it never needs to be processed again and the browser will look directly for image.jpg rather than script.php?src=image.jpg etc.

My problem is, i use Wordpress with custom fields to show images...the contents of which are:

http://domain.com/wp-content/uploads/2008/image.jpg

I currently use a script to resize images which looks like this:

script.php?src=http://domain.com/wp-content/uploads/2008/image.jpg&h=100&w=100

The problem with the above article is the format in which you give your image its height and width attributes, like this:

image.100x100.jpg

Obviously this is a problem for me, as i already have many articles with custom fields as above, with the full path and filename.jpg.

My question is - is there any way to do this without having to manually add .100x100 into each custom field for all my articles? At the moment after a file is uploaded via Wordpress you can just copy/paste the provided URL to the filename into the custom field...i really don't want to have to add dimensions in manually as other people will forget when posting!

Many thanks in advance for any ideas...
 

Thanks for your response

Unless i'm mistaken wouldn't that mean you still have something like script.php?image.jpg?h=300&w=300, rather than a nice clean image300300.jpg that can be loaded directly without the need for PHP if its already cached?

I was thinking maybe i could use some PHP to take my "custom field" file path e.g. http://domain.com/images/test.jpg and just re-do the output so i could add 100x100 (or whatever sizes i want) before the .jpg, leaving the original code from that article intact?
 
Back
Top Bottom