[wp-hackers] Inclusion of TimThumb -- anyone game?

Paul paul at codehooligans.com
Thu Mar 5 19:49:05 GMT 2009


I have a better solution. I wrote a Media Tags plugin back Dec 2008 so  
I can stop asking the client to name the image with a certain pattern.  
Now when the image is uploaded they can simply 'tag' the image as  
needed. Most of the time the tags don't change. But the client wants  
to upload a new version of a sidebar image or whatever.

Hosted on wordpress.org http://wordpress.org/extend/plugins/media-tags/
See details on the plugin here: http://www.codehooligans.com/2008/12/14/media-tags-plugin/

This plugin also help prevent the spread of hard-coded SQL commands in  
your template code that may break if/when WP core schema changes. All  
you need to do in your loop is call the function like this:

$media_items = $mediatags- 
 >get_media_by_tag('media_tags=sidebar&post_parent='. $post->ID);

Replace 'sidebar' with the tag marked for the image. The $media_items  
returned will be an array. Then you can call the  
wp_get_attachment_image() function as suggested.

Paul




On Mar 5, 2009, at 1:40 PM, Glenn Ansley wrote:

> I've done this for clients in the past like this:
>
> 1) Tell them upload an image to their post (but don't actually "send
> to editor". Just upload so its associated with the post).
> 2) Tell them to title it something specific like post_image, icon, or
> whatever you want.
>
> Then, in your php loop
> * Use this psuedo code:  select id from wp_posts where type is image
> and parent is [current post] and post_title is [post_splash] limit 1
> * Run it through <?php wp_get_attachment_image( $image_id ,
> array(75,75), false); ?> and you're golden. (second argument - the
> array - is your image dimentions)
>
> BTW, there are a lot of cool functions / filters when you start
> digging through wp_get_attachment_image and the functions it depends
> on. They're all in wp-includes/media.php.... including image_resize();
>
> Glenn Ansley
> Custom WordPress Plugins
> http://fullthrottledevelopment.com
>
> On Thu, Mar 5, 2009 at 2:28 PM, Casey Bisson  
> <casey.bisson at gmail.com> wrote:
>>
>>
>> What's needed for that is for WP to have a function like the_icon()  
>> or
>> the_image() that works like the_content() and and the_title(). The  
>> question,
>> however, is how to set that image when creating posts.
>>
>> I implemented something like that in my bSuite plugin; it adds a  
>> metabox to
>> the post/page editor that allows post authors to define the "icon"
>> representing the post. Still, I'd love for WordPress to have a  
>> similar
>> feature built-in.
>>
>> bSuite:
>> http://wordpress.org/extend/plugins/bsuite/
>>
>> --Casey
>>
>> http://maisonbisson.com/
>> http://about.scriblio.net/
>>
>> On Mar 5, 2009, at 2:13 PM, Nathan Rice wrote:
>>
>>> Doug,
>>> WordPress already includes an image resizing feature when you  
>>> upload new
>>> images (creates a medium and thumbnail size image).  However, I've  
>>> been a
>>> little curious as to how plugin/theme developers can use those  
>>> features
>>> themselves.
>>>
>>> I'd like to formally ask for the hackers' help on this one.  If  
>>> there is a
>>> way for a theme/plugin to take advantage of the image upload and  
>>> resize
>>> functions, I'd certainly appreciate a point in the right direction.
>>>
>>> As far as timthumb, I don't think it would be necessary in core if  
>>> the
>>> same
>>> thing could be accomplished using pre-existing WordPress functions.
>>>
>>> Nathan
>>>
>>> My Website
>>> http://www.nathanrice.net/
>>>
>>> My Twitter
>>> http://twitter.com/nathanrice
>>>
>>>
>>> On Thu, Mar 5, 2009 at 1:36 PM, <zamoose at gmail.com> wrote:
>>>
>>>> I've noticed a lot of "premium" themes (most recent being the
>>>> Ma.tt-linked
>>>> Smashing Magazeen) are starting to include TimThumb along with  
>>>> their
>>>> themes.
>>>> Easy thumbnail generation, allows for a lot of flexibility on theme
>>>> authors'
>>>> parts, etc. MIT-licensed.
>>>>
>>>> (Must have GD installed, of course, for it to work.)
>>>>
>>>> So, that being said, the question arises: does anyone else see a  
>>>> use case
>>>> for including it in WordPress? Recall we had similar discussions  
>>>> in re:
>>>> inclusion of the various JS libraries and "include 'em all and  
>>>> let the
>>>> plugin/theme devs sort it out!" was the eventual decision. Oh,  
>>>> and the
>>>> wonderful wp_enqueue_script() functionality followed...
>>>>
>>>> Grist for the mill, but I come down on the "tentative 'yes'" side  
>>>> of
>>>> things.
>>>>
>>>> -Doug
>>>> http://literalbarrage.org/blog/
>>>> _______________________________________________
>>>> wp-hackers mailing list
>>>> wp-hackers at lists.automattic.com
>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>>
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> _______________________________________________
> 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