(Wordpress)的Php图像调整大小/缩略图方法

问题描述:

My goal is to create a website for a client that needs the site to be heavily based as image galleries.

I am making the site through Wordpress so the client can upload the pictures through the friendly wordpress admin panel and then the site will display a parent image for the gallery and several thumbnails (scrolling with Jquery).

My question is for advice on good ways to resize the images as thumbnails. Currently I have some "hack-ish" code that simply changes the image dimensions, but as far as I know this doesn't reduce loading time and is quite inefficient.

Any ides on how to do it better? Possibly by using PHP GD? Thanks!

我的目标是为客户创建一个网站,该网站需要将网站大量作为图像库。 p>

我通过Wordpress制作网站,以便客户端可以通过友好的wordpress管理面板上传图片,然后网站将显示图库的父图像和几个缩略图(使用Jquery滚动 )。 p>

我的问题是关于以缩略图的形式调整图像大小的好方法的建议。 目前我有一些“hack-ish”代码只是简单地改变了图像尺寸,但据我所知,这并没有减少加载时间并且效率非常低。 p>

关于如何做的任何想法 做得更好? 可能使用PHP GD? 谢谢! p> div>

Timthumb might be a good solution for this. The built-in wordpress media settings can only be set once for three different image options (thumbnail, medium and large). If you change the settings, anything already uploaded won't be readjusted. Most of the time this is acceptable, but for a photo heavy site, you might need more size options and dynamic adjustments. This simple php script will create any size image and save a cache copy for quick delivery. Lots of WordPress themes use it.

http://code.google.com/p/timthumb/

-- EDIT --

So, you know that advice about TimThumb I gave yesterday? Well, check out the big news today. Just make sure you're using the latest version.

http://ma.tt/2011/08/the-timthumb-saga/

Wordpress already does this on successful upload.

Besides creating the standard set of thumbnail, medium and large sizes, you can also enter custom sizes to create under the Settings -> Media section of the dashboard.

You can also add custom sizes in plugins and / or themes. See http://codex.wordpress.org/Function_Reference/add_image_size

WordPress his this nifty function tucked away image_resize, I'd recommend that if your looking to do this on the code size in one location. I have a small "library" I wrote to "help" with handling file uploads in WordPress, the git repo is here.