开发者

Php image resize/thumbnail approach for (Wordpress)

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开发者_Python百科 better? Possibly by using PHP GD? Thanks!


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


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 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜