TwentyEleven With Easy Rotating Header Images

I have a secondary blog which I wanted to have some special header images. One nice thing about the new default WordPress theme, TwentyEleven, is that you can have a couple of header images and rotate them randomly. A bad thing about the new default WordPress theme is that it’s annoying adding new header images.

At first I got this post about adding your own images. One thing I did a bit different was the way I was generating thumbnails with the same name of the image, but in a different directory. Because of that, all I really needed was the image name. Thus, my wptis_new_default_header_images() turned into:

function wptips_new_default_header_images() {
    $dir = get_bloginfo('stylesheet_directory');
    $headers = array(
        'image1',
        'image2',
        'image3',
        'image4'
    );

    $images = array()
    foreach($headers as $filename) {
        $images[] = array(
            'url' => "$dir/images/$filename.jpg",
            'thumbnail_url' => "$dir/images/thumbs/$filename.jpg",
            'description' => __($filename, 'twentyelevenheaders')
        );
    }
    register_default_headers($images);
}

This way, when I needed to add a new header, all I had to do was upload it to the theme package (with the thumbnail) and edit the $headers array to add the new filename.

But that was a bit annoying ’cause, well, I had to create the thumbnail, upload both the image and the thumbnail and then edit the function again. That’s when it occurred to me that I could make a page, add a gallery to it and then make the theme load the images from that gallery. That way, I could use WordPress itself to upload the images and let it create the thumbnails. The result was this:

function wptips_new_default_header_images() {
	$child2011_dir = get_bloginfo('stylesheet_directory');
	$images = array();

	$page = get_page_by_title('The Headers');
	$attachments = get_children(
		array(
			'post_parent' => $page->ID,
			'post_type' => 'attachment',
			'orderby' => 'menu_order ASC, ID',
			'order' => 'DESC'
		) 
	);
	foreach($attachments as $id => $info) {
		$image_id = $info->ID;
		$url = wp_get_attachment_image_src($image_id, 'full');
		$thumb = wp_get_attachment_image_src($image_id, 'medium');
		$images[] = array(
			'url' => $url[0],
			'thumbnail_url' =>  $thumb[0],
			'description' => __($info->post_title, 'twentyelevenheaders')
		);
	}

    register_default_headers($images);
}

After that, I created a page named “The Headers” and uploaded all images I wanted (following the guildelines of 1000×288) and let WordPress take care of the rest, including saving them on the server and creating the thumbnail. The thumbnail is a bit larger than the normal size, but that’s not a big issue IMHO.

Anyway, if you’re interested, here is the theme. Install like any other WordPress theme, but you’ll need a page named “The Headers” for it to work (or create a page and change the name in the code).

Of Jobs, rms and Ritchie

Last two weeks were a complete train-wreck for people in IT: First, Steve Jobs died on October 5. I thought I should write something to “enlighten” some people saying things like “Oh, he did some gadgets, so what?” But, when I was waiting for the dust to settle, rms came with an statement that inflamed a lot of people, including some asking “What this Stallman wrote, after all?” Le sigh. And, again waiting for the dust to settle, another lost: Dennis Ritchie died a week after Jobs. And no press really cared.

But let’s close those points:

First, we have Steve Jobs. Yeah, he was a capitalist who commanded one huge company who did care about creating devices where under their total control.

But, at the same time, he was the helmsman of a company that disrupted everything other companies were doing. In IT, we have the expression of “disruptive technology”, which are things created the shake the market completely. Linux is such thing. And Apple products are other. Tablets changed and got accepted when Apple launched the iPad, even if the idea of such devices predates the device by a long time. Smartphones weren’t really smart till Apple launched the iPhone; MP3 players only became a mass market thing after the iPod; and suddenly we have a whole new wave of ultra-thin notebooks coming around after the MacBook Air.

Apple did hold control of everything they did, yes. But you can’t deny how disruptive the company was for the IT market.

But there is one thing that tops it all: HTML5. When HTML5 was just a thing coming out of draft, Jobs was the voice saying “Kill Flash, ’cause HTML5 is the future”. Sure, he had his motives (the fact that his company hold part of the video standard was one of those), but HTML5 became a big thing when Apple started pushing it. Or would you prefer Adobe position of, for example, saying that “Linux is hard, so no acceleration there” instead of Mozilla position of “We recognize there is a problem with accelerated WebGL/Canvas on Linux, but we are willing to work with developers to improve this situation”?

And then Richard Stallman, also known as “rms” (yes, lower case), came with some… erm… “rude” words about Steve Jobs. And then people came with “And what have this Stallman done? Nothing.”

Well, dear sirs, Stallman is the helmsman of the Free Software Foundation and the creator of the GNU project. The very first thing rms created was the Emacs editor, which influenced the readline library, which influenced, for example, the OS X shortcuts. Oh, and his second project was a compiler called “gcc”, which was the only compiler on XCode till version 3 (version 4 also uses LLVM, but that’s a completely different beast). And what’s XCode? It’s the official application for creating iOS applications. Oh yeah, ladies and gentlemen, part of the success of Apple can be be attributed to the guy that dissed Jobs days after his death.

Not only that, but gcc was the official compiler for NeXTSTEP, the operating system that Jobs started after being fired from Apple. And hey, guess what? NeXTSTEP is the reason Apple bought NeXT and, as Jobs said himself, “was the base of the renaissance of Apple”. Would NeXTSTEP be such interesting operating system for Apple if they had to take the time to design their own compiler?

And, after you brush off the politics of rms message… Can you point anything wrong with it? Isn’t Apple the company that pushed a completely controlled environment? Isn’t that the completely opposite vision of what rms have for software?

And then, on October 12th, Dennis Ritchie died. Ritchie was the co-creator of Unix operating system and the C language.

“Whateves” is what those attacking rms and saying “meh” to Jobs are probably thinking now. Unix is the power behind OS X today (with the Mach kernel) and its main developing language is Objective C, which is C with some added features (Wikipedia page lists it as “adds Smalltalk-style messaging to the C programming language).

Not only that, but rms idea with the GNU project was to create a completely open source Unix — which later was achieved with the help of the Linux kernel — including a C compiler (the gcc I mentioned before).

If Apple went long, it’s because it stood in the shoulders of giants like rms. If rms managed to fulfill his dream of an open source operating system, it’s because he stood in the shoulders of giants like Dennis Ritchie.

You May Have Talent, But You’re Not an Underdog

There is yet another video floating around about a kid in some “Got Talent”-like show, telling his sad history and then singing in some ok fashion.

Now you must be asking yourself “What video is this?” and that’s the core of the point I’m trying to make: Every single “Got Talent” video that hits the web is about some kid, man or woman who had some hard time in their lives and then got a chance at the show. Sure, there is the eventual “person who sings/dances/talks incredible bad it’s too funny to pass away”, but the great majority is the underdog who finally got their chance.

So this kid from a middle class family, who managed to get some guitar/singing lessons from time to time, managed to have his time to practice and such, learnt the tricks of trade, created a band with some friends, practices every weekend… well, sorry for you, you don’t “Got Talent” ’cause you’re not an underdog.

Kinda reminds me of those “Reality TV” shows where people are invited and they have to do some crazy shit. I mean, what’s the reality when you have to stay standing for 12+ hours non-stop? Do you stay 12+ standing non-stop at your house, by any chance?