[wp-hackers] avoiding of using phpThumb / timThumb

Otto otto at ottodestruct.com
Thu Mar 31 17:38:08 UTC 2011

Using add_image_size is indeed the correct way to go, but the real question
is why would you need "tens" of image sizes? Are you really displaying the
same image in ten different places, ten different sizes?

If some of these sizes are similar or close enough together, then you can
use a combination of image resizing and browser resizing. Let's say I only
have it generate three image sizes normally. Then I try to display an image,
but instead of passing it a size, I pass it an array(width,height). This
works, but what it does internally is that it looks at what image sizes it
has, grabs the one that's closest (but bigger), does the scaling math, and
then pops back an IMG tag with the width and height set correctly, but using
that slightly larger image. This makes the browser itself scale the image
down, giving me the best approximation and not requiring me to do all the
server resizing and such.

Realistically, you're not going to run out of execution time with "tens" of
image sizes though. It can generally handle it just fine. I've gone up to
six for a site with no significant problems. Resizing isn't a slow
operation, it's just heavy on temporary memory usage.


On Thu, Mar 31, 2011 at 11:04 AM, Konrad Karpieszuk
<kkarpieszuk at gmail.com>wrote:

> hello
> on site which i create now, i will have many areas with photos and
> those photos must be rescaled befor displaying. normally to do this i
> use phpThumb with ?w=100&h=200 etc.
> Is there any other way to do this using wordpress core functions?
> I thought to use  add_image_size to automatically rescale image when
> is uploaded. but if i choose this way, i am affraid that this will not
> work. i should register tens of image sizes. when smb will upload
> photo i can expect that when wordpress will save this image with
> rescaled many variants in one moment php will exceed memory limit.
> is there any function which i can use in way like phpThumb? this
> should rescale image (with crop option) but before this check if
> already rescaled version exists
> --
> (en) regards / (pl) pozdrawiam
> Konrad Karpieszuk
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list