Justin Gable

Note to self: You can’t fly

The last time I got to ride we did the last 2 mile section of 007 at Bass Lake. It is by far the most entertaining trail I’ve done; tons of technical challenges, huge ruts, couple rock gardens, and best of all, jumps. We hiked up from the road so I was able to see all the obstacles in detail before hand. The ruts were insane since the trail is shared with dirt bikes.

When we started, there were a few smaller ramps where I was able to get a whole whopping 6″ of air. Now, mind you, I’ve only been mountain biking for a little over 4 months, and jumps aren’t something I’ve really had an opportunity to try out or practice. Nonetheless, it got me excited… and maybe a little over confident. The next turn was a steep decline (about 20′ long) ending with a nice little ramp that continued downhill a ways. I remembered it from the hike up, making a mental note to be sure to slow down for it, but ripe with my 6″ flight through air victory, I told myself “F@$# it! Don’t touch the brakes, just see what happens!”

What I remember

On the way down the slope I chose my launch point and hit it going relatively fast (17-20). While in the air I realized I forgot one key element in this whole adventure… where the hell I was going to land. My front tire caught the top of a rut and slid in, slamming the bike and myself to the ground, smashing the light and computer that were mounted on the handle bars in the process. My knee and elbow hit square with the ground and the force pushed my arm back up into my shoulder, tearing something in my back (where my shoulder blade is attached). I rolled and landed on my side, knocking the wind out of me. When I stood back up I noted my tire marks were about 6 feet from where I hit the ramp. Not too shabby.

Moving On

I wound up with quite a few cuts and bruises (my both my knees and calves were completely bruised) and still can’t sleep on my right side, but honest to God it was absolutely worth it! That was the most exhilarating thing I’ve done in a while and I can’t wait to give it another shot, though this time I’m going to be a bit more prepared. Look what the birthday fairy brought me…

It’s been 2 1/2 weeks since I’ve been able to ride a trail, and I’m seriously going through withdrawals. Saturdays are the only real chance I get to go do them and I’ve been busy (and maybe a little injured) the last two, but this Saturday I get to go again. Not sure what we’re planning on doing, but I don’t care, I just need something.

Modifying Wordpress’ default method for inserting media

Working on a client site this week I wanted to change the way that Wordpress inserts media into posts. Right now if you were to upload a flash movie (FLV) and click the “Insert into post” button, Wordpress injects the title of the file linking to the file you just uploaded (ex - <a href="http://yoursite.com/wp-content/uploads/movie.flv">The Title</a>).

I wanted Wordpress to output the data in a custom shortcode (ex -[flash http://yoursite.com/wp-content/uploads/movie.flv]). I have a plugin that will take that shortcode and turn it into an embedded flash video automatically. This makes it incredibly easy for a client to add flash movies and mp3’s to their posts.

So what did I do to change the output?

Filters FTW

Searching around the source code of Wordpress I came across the filter media_send_to_editor in /wp-admin/includes/media.php on line 291 (there is also image_send_to_editor on line 63 for those who are interested). Now that I found the filter I just needed to write a basic plugin to modify the output.

<?php
/*
Plugin Name: EWM Modified Media Insert
Description: Modifies the default method for injecting media into posts
Author: Element Web Media
Version: 1.0
Author URI: http://www.elementwebmedia.com/
*/

class ewmInsertMedia {
  //class constructor
  function ewmInsertMedia () {
    add_filter('media_send_to_editor', array($this, modifyMediaInsert) , 10, 3);
  }
  //function that does the modifying
  function modifyMediaInsert($html, $send_id, $attachment) {
    $output = '[flash '.$attachment['url'].']';
    return $output;
  }
}
//instantiate the class
$ewmIM = new ewmInsertMedia();
?>

There are a total of 5 values that are available in the $attachment array:

  • url
  • menu_order
  • post_title*
  • post_excerpt*
  • post_content*

* It says “post_” but the values are not that of the actual post but the info of the file. I’m not sure why they chose those particular terms to describe the values, it just makes it confusing imho. I remember now that Wordpress stores media entry data in the wp_posts table. That’s why it’s post_title, post_excerpt, etc.

Going beyond

The shortcode API is awesome, if you haven’t messed around with it yet I urge you to take a look at the documentaion. This discovery has inspired me to start working on my own flash plugin, one that’s seamlessly implemented and without all the extra bloat (unnecessary header requests, etc). Maybe I’ll post it here when I’m done, we’ll see :).

A look at Wordpress 2.7

Sometime at the end of the year we can expect to see the next point version update for Wordpress (2.7). Those familiar with Wordpress know that with version 2.5 the blogging engine received a major, much needed, overhaul to the backend and a plethora of new features, so if you’re not expecting much out of 2.7 you’re in for a surprise. This update looks to add just as many features, if not more than 2.5, along with a restructuring of the backend layout, most notably the move from a horizontal-top navigation bar to an accordion style vertical-left nav.

This change and many of the other visual elements are being made to favor widescreen monitors. I’m glad they finally realized that the top style nav didn’t lend itself well to being extensible, with each plugin usually adding at least one nav link. Anyone who uses more than a few plugins knows what I’m talking about.

Add/Edit Post page (The Write-panel)

The write-panel received it’s fair share of “improvements”. Fans of the old school drag and drop elements will be happy to know that they’ve made a return. You can now drag and drop any of the element boxes between the right hand column and the column under the content box. They’ve gone a step further and added the ability to hide element boxes that you don’t want to see. Though, my thought is that these settings should be available through the settings menu rather than on the write-panel.

Plugin Repository

The change I’m most excited about is the ability to search the Wordpress plugin repository, select and install plugins, all from the backend of Wordpress! It’s all automated and very slick, no more having to download plugins, unzip them and then upload them manually. The only thing lacking about this addition is that the search flat out sucks. You’ll know this if you’ve ever tried to look for any plugins from http://wordpress.org/extend/plugins/, you get too many irrelevant plugins and typically the one you are looking for is buried at least a couple pages in.

Other notable additions

  • ability to make posts “sticky”
  • inline editing of posts from the front end
  • comments XMLRPC API
  • automated Wordpress updates
  • new HTTP request API (looking forward to that one)
  • built-in threaded comments (woo-hoo)
  • ability to reply to comments from the backend
  • added global settings for images (an addition size “Large”)
  • “Inbox” (this feature is not complete so I’m not sure exactly what it is going to be officially, however I’m guessing they are adding in some sort of built-in contact form… which would make a whole lot of sense)
  • QuickPress - a widget on the dashboard for quickly creating a post. (Honestly, kind of pointless, who doesn’t have time to click a link to get to the post page (there are 2 links on the page already)
  • media buttons consolidated to single “Add Media” button, this may only be for development and will probably go back to the 4 original buttons)

Not ready for primetime

Right now 2.7 isn’t ready for use on a production blog, some of the features are broken or completely disabled. However, if you want to get your hands dirty and try out the software you can get the latest nightly build here (scroll to the bottom and click the “Zip Archive” link). Have fun.

My New Ride

Yesterday I got to pick up my new 2-wheeled companion from Performance Bicycles (very nice guys over there, Pablo & Casey). The GT I-Drive 5 is a definite step up from my Jamis Durango hardtail. Having full suspension is going to be a nice breath of fresh air for the downhill. Perhaps screaming down the side of a loose rock mountain at 35 mph won’t be as terrifying without the backend feeling like it’s going to come apart at any moment.

I’m in the process of moving my gear over to my new bike, one big downer is that I lost a mounting point for an extra water bottle and/or air pump. The air pump I had to get has a horrible mount, we’ll see if it manages to hold on to the frame very long. As a bonus I now have a bike to loan out to anyone who would like to tag along on the trail some weekend.