As much as web developers complain about the lack of standards support in Internet Explorer (when they’re developing on Firefox), it’s really quite another ballgame confronting the variety of syndication standards and newsreaders out there. I was recently responsible for developing and implementing a new feed generation mechanism for the O’Reilly Network family of sites (oreillynet.com, windowsdevcenter.com, macdevcenter.com, linuxdevcenter.com, onjava.com, ondotnet.com, onlamp.com, perl.com, xml.com, among others) that would bring up our standards support and allow us to include some additional content in our feeds like graphics and enclosures.
When the Atom 1.0 standard was released, I was able to have our new feeds compliant that afternoon. The problem of course is that there’s been a lag in the Atom 1.0 support in the newsreaders out there. Case in point. The other day I removed the rel="alternate" attribute from the atom:link element–I was informed it was actually optional. So I was not surprised this morning to get two bug reports from Safari RSS users that post titles were no longer linking to the actual post entry.
I put the rel="alternate" back in and Safari RSS again links to our posts. Yey. rel="alternate" is mandatory for Safari RSS. We’ve gotten reports that Akregator (a KDE newsreader) is complaining about our Atom feeds. NetNewsWire 2.0.1 which supposedly supports Atom 1.0 does not find any items in our feeds. Bloglines performs admirably, but removes whitespace around links in atom:summary elements. The good news is that if you plug our feeds into the Feed Validator, we get a thumbs up.
Hopefully these issues will be hashed out as the standard is more widely adopted. In the meantime, any of our Atom 1.0 feeds are also available in either the RSS 1.0 or the RSS 2.0 format. So if the Atom Mac DevCenter feed (http://www.oreillynet.com/pub/feed/3) is not working for you, you can request the RSS 2.0 version by adding ?format=rss2 to the URL: http://www.oreillynet.com/pub/feed/3?format=rss2. Cool huh?
This post first appeared on From the Belly of the Beasts, a weblog from some of the people who build O’Reilly websites.
One of my biggest pet peeves is the misuse of the word “blog” when referring to a single post on a weblog. I was just reading A Rendezvous With Microsoft’s Deep Throat (how could you not with a title like that?) and noticed at the end of the article a header that read “For some of Mini’s most popular blogs, check out:” followed by a list of popular posts.
Unfortunately this misuse exists here at O’Reilly, as we have bloggers who submit their posts into one big system (weblogs.oreilly.com) without any sort of individual blog identity or blog name. Since the traditional notion of a blog (definition: a collection of posts composed by a single person [or cabal], ordered in reverse chronological order) doesn’t really exist, people’s posts are referred to as “weblogs” (e.g. Todd Ogasawara’s author page) which can be filtered by author or topic.
As we continue to develop and improve the O’Reilly Network, my hope is that we can organize our bloggers around subject oriented group blogs—and start referring to posts as posts.
This post first appeared on From the Belly of the Beasts, a weblog from some of the people who build O’Reilly websites.
The latest version is 5.0, released June 20, 2008, now with support for WordPress 2.5 galleries, and still backwards compatible with 2.3, 2.2, 2.1, and 1.5
Inspiration
One of the things I’ve been thinking about more since starting at O’Reilly is how to draw attention to a back catalog of content. For a single blogger, it’s pretty easy to link back to a relevant old post because of the information retrieval processor built into our heads. But for a site managed by an editor who may not be as familiar with the back catalog, the older content will languish, accessible only by search engines.
Then the other day I discovered the most amazing thing. I was freshening up the layout of O’Reilly’s Mac DevCenter, and we decided it would be cool to have a randomly populated book sidebar. Which meant I needed to pull records out of our database in random order—not something I’d ever needed to do before. It turns out that the SQL needed to do this is astoundingly simple:
SELECT *
FROM table
ORDER BY RAND();
Maybe you only want a single random record? Easy.
SELECT *
FROM table
ORDER BY RAND()
LIMIT 1;
Seeing this in action for the first time is like a revelation.
What does this plugin do?
Since I started blogging, I’ve added 500+ images to my blog posts, and I’ve always wanted some way to index them, or make them accessible in aggregate. I wrote a script once that generated a webpage to display all the images, but I had no means (at the time) to link them back to their associated blog posts.
Of course since I moved to WordPress, I have complete control over my content, so I decided to write a plugin to look for blog posts with images and return one image at random, linking back to its post. Update: If you prefer, you can now configure this plugin to display images in reverse chronological order (most recent to least recent) rather than in random order.
You can see it in action in the upper-righthand corner of my homepage. Here’s a screenshot:
What doesn’t this plugin do?
This plugin does not rotate randomly through a group of images stored in a single directory on your webserver. If you are looking for a plugin to do that, try Matt Mullenweg’s A Rotater Apartor Kamiel Martinet’s WordPress random header plugin or MHough’s Header Image Rotator.
This plugin does not natively resize images (you can use the CSS on the optional image attribute parameter to resize the image in the browser). Which means it does not create thumbnails, create square thumbnail images, nor have any knowledge of how or where your WordPress-generated thumbnail images are stored. It simply looks for a random image that you’ve embedded in the content of your post (or gallery) and returns it. This ensures that it always correctly returns an image that actually exists.
Upload the file randomimage-standalone.php to your plugins directory (alongside randomimage.php):
/path/to/wordpress/wp-content/plugins
Note: This is not a separate plugin, it’s simply a supporting file for randomimage.php, therefore there is nothing you need to activate or configure.
On the other blog (or any website, really) where you want the random image to appear, insert the following HTML snippet, replacing example.com/wordpress with the domain name (and directory, if any) where randomimage-standalone.php lives
Note: for the random image to be appear, JavaScript much be enabled in the browser.
Options
The randomimage function can take 12 optional parameters in between the parentheses. If you specify any parameters this way, all settings made through the configuration interface (shown above) will be ignored. Note: this behavior could be useful if you wanted to have several different random images each with different settings appearing throughout your site.
show_post_title is a boolean (true or false) that determines whether the title of the original blog post is printed above the image. The default is true.
number_of_images is an integer that determines how many random images the function should return. The default is 1.
image_attributes is a string that gets inserted in the img tag which you can use to set attributes like a standard width or a title (tooltip). The default is an empty string. For example, "width='200'" would reduce the size of the image to be 200 pixels wide (and proportionally high).
show_alt_caption is a boolean (true or false) that determines whether the alt attribute (if there is one) is printed below the image. The default is true. (new in v1.2)
image_src_regex is a string containing a regular expression (without slashes) that matches against the image src attribute. For example, if you only wanted to display jpg’s and png’s, you would use "(\.jpg|\.jpeg|\.png)". If you only wanted to display images from a specific directory called images, you could use "images". This parameter uses the preg_match php function in case-insensitive mode. For more information on constructing regular expressions, check out regular-expressions.info. (new in v1.2)
post_type is a string that allows the following three values: posts for including images from post content only, pages for including images from page content only, and both for including images from posts and pages. The default is posts only. (new in v1.3)
inter_post_html is a string (presumably HTML) that is outputted between subsequent images if number_of_images is greater than 1. The default is <br /><br />. (new in v1.4)
category_filter is a comma-separated value string of numerical category IDs that will limit the plugin to grabbing images from posts assigned to only those categories. The category IDs can be determined by going to Manage > Categories. The default is an empty string which will allow images from posts assigned to any category. (new in v2.1) Even though the name hasn’t changed, this option now includes tags too! (new in v4.1)
sort_images_randomly is a boolean (true or false) that determines whether the image (or images) pulled from the database are displayed randomly or in reverse chronological order. By setting this option to false, the plugin effectively displays recent images, rather than random images. The default is true. (new in v3.0)
image_class_match is a string that you can use to specify a classname that the randomly chosen image’s class attribute must contain. So if you set it to randomimage, only images with class="randomimage" (or even class="left randomimage") will be displayed. (new in v4.0)
image_template_html is a string that acts as a template for displaying the image. With it you can create wrapper HTML around the image, or position the caption on top, or a myriad other things this plugin author hasn’t conceived. Use %1 in the template to represent the title, %2 to represent the image, %3 to represent the caption, and %4 to represent the post excerpt. By default, the template is:
<strong>%1</strong><br />
%2<br />
<em>%3</em>
Note: If image_template_html is specified, it overrides show_post_title and show_alt_caption. (new in v4.0)
show_images_in_galleries is a boolean (true or false) that determines whether the plugin should show images from WordPress 2.5’s new gallery feature. The default is true. (new in v5.0)
If you wanted to use all the options together, you might add the following to your index.php or sidebar.php file:
Suppress printing caption if it’s the same as the image filename
Check image dimensions to prevent enlarging small images (?)
Add option to only display images within a certain width/height range
Add a check to make sure image exists
Optionally create a thumbnail of configurable dimensions (hard)
Store post image info in the postmeta table (hard)
Questions, comments, and suggestions are always welcome. If you’re interested in contributing to the code behind the Random Image plugin, it’s hosted on GitHub.
I wasn’t able to publish the previous post until moments ago because the wireless at the BlogHer conference was wholly inaccessible. I could connect to the access points, but the dang things wouldn’t give me an IP address. Of course this was more distracting than the intarweb itself because I instantly switched into troubleshooting mode, trying to figure out what combination of settings might trigger my integrated wireless card to start flirting with their wireless access points. Other than the brief access I happened upon early in the morning, for the rest of the day, it felt like I was in my own personal dead zone.
I went to a session about hip-hop blogging and feminism, which sounded awesome, led by Lynne D Johnson who was well-spoken, had interesting experience to talk about (currently being the online manager at Spin and Vibe magazines), and had a good deal of knowledge about black feminist writings, such as bell hooks’ Misogyny, gangsta rap, and The Piano (to read later).
However, one of the people attending the session (who turned out to be Ponzi, girlfriend of Chris Pirillo) asked if she could have permission to “podcast” the session. I figured this meant unobtrusively record the speaker and the audience’s questions from a distance. Instead she proceeded to take over the session, interrupting Lynne to ask questions, and otherwise being rather intrusive. Even I felt uncomfortable. Brave new world indeed. Update: Ponzi responds and reflects on the ethics of podcasting. Justin wishes his criticism had been more constructive.
Toward the end, I excused myself and hopped in the car heading towards Woodside for the Bay Area Carolina Club’s Annual BBQ. It was just freaking terrific. I even recognized a few people, which I’d hoped for. There’s nothing like a familiar face, even if you’ve got to play 20 questions trying to figure out why the face seems familiar. Anyway, the barbecue pretty closely resembled what I remembered from North Carolina in terms of taste and texture—though I believe he used crushed black pepper in the seasoning instead of crushed red pepper.
It was 2pm when I said my goodbyes and got back on I-280, which meant I had completely missed getting to hear Heather Armstrong. Bah. Given the overall zeal of the podcasters/vloggers, I can only hope to hear it later. In the meantime sacredwhore has notes.
Bed at 2am, alarm at 6. On 101 heading south just after 7. The fog is out, which I know is fog and not just overcast morning haze because my windshield gets wet very slowly. Maybe it’s because I drive my car back and forth to work everyday (previously I rode my bike), but my shiny black car gets much dirtier in California (where is doesn’t rain!) than it did in NC. Ok that’s totally not true, there are those two or so weeks in the spring when the pine trees get all randy and exploded in orgasms of neon green pollen. Which coated everything. Especially cars.
The BlogHer conference started early, and I managed to get there exactly at 8:30am (on time!), walked into the back of the main hall just as the organizers were introducing themselves. Among the 270 odd attendees, there was ae right in front of me, a familiar face from the Chapel Hill blogger meetups.
As I type everyone is gathered into ad hoc birds of a feather sessions on various topics, and I’m slinking back, feigning professional objectivity, in reality just being too tired to socialize, but everyone talking f2f means I can actually get on the previously overloaded wireless network. They called these BoFs “blog crushes”, and so far I’ve seen Heather Armstrong and Mena Trott, two people who I’d probably have a crush on if I read their blogs more regularly. Ah, the social construct of fame. I still hold that blogging is a form of personal fame creation (or emulation). The crazy truth is that they are all real people—my virtual familiar strangers.
I have one complication. The Bay Area Carolina Club is having their annual BBQ about 30 minutes from here, so I’ll be leaving just before lunch, dropping in to meet up with the Tarheel diaspora, and seeing whether it’s possible to get “real Carolina BBQ” out west. Then I’ll race back and try to catch the tail end of the session with the Dooce herself.