What’s that close paren doing after my video embed in WordPress?

Working on a new client site that has a lot of YouTube video embeds, I was alarmed this morning to find a stray close paren ) character in all of the posts right after the videos.

Knowing I had recently been tampering with the embed_handler_html and embed_oembed_html filters in the site theme, I figured it was something I had created. So I set about debugging my code but couldn’t get anywhere.

I decided to see if it was in fact a new problem in WordPress itself, by setting up a test post on this site with a YouTube video embed (this, of course). Sure enough, even on my unadulterated theme, the stray close paren appears.

Look at it!!!I mean, just look at it!!!

Anyway, I hope/assume this will get fixed in the WordPress core soon, but in the meantime if you are running into this problem and want a quick fix, and you’re not afraid of editing the functions.php file in your theme, have a go at this little addition that will strip out the offending punctuation:

function embed_fix_stray_parens($content) {
    return str_replace('</iframe>)','</iframe>',$content);
}
add_filter('the_content','embed_fix_stray_parens');

Update #1: I went to submit a bug report to the WordPress development team and found my report was a duplicate of this one. If I understand correctly, the close paren is actually being delivered by YouTube itself, not WordPress, via the oEmbed request. Isn’t the Internet fun?

Update #2: This really is YouTube’s problem… it even shows up in the embed code you get on their own site:

Screen Shot 2014-03-12 at 11.00.12 AM

This issue is also showing up on StackOverflow now, including a more efficient temporary workaround for WordPress sites than my own hasty solution.

The Mother of All Funk Chords

I just had to pile on to the mountain of people sharing this because it’s so cool:

Merlin Mann pretty much sums it up:

Unsolicited tip for media company c-levels: if your reaction to this crate of magic is “Hm. I wonder how we’d go about suing someone who ‘did this’ with our IP?” instead of, “Holy crap, clearly, this is the freaking future of entertainment,” it’s probably time to put some ramen on your Visa and start making stuff up for your LinkedIn page.

Because, this is what your new Elvis looks like, gang. And, eventually somebody will figure out (and publicly admit) that Kutiman, and any number of his peers on the “To-Sue” list, should be passed from Legal down to A&R.

Now, about that new car…

Honda FitIn my previous post (written an hour or so ago) I mentioned car dealerships calling me.

That’s because, as I prepare to start a new job in the suburbs, I find I must, with regret, say goodbye to light rail transit and return to the world of commuting by car. Since we presently have only one car (the 2000 Civic I bought the last time I started a new job in the suburbs), and with the added scheduling complexity of life with kids, it’s time to get another one.

Thinking “family,” we had been eyeing the Subaru Forester for quite some time. It has lots of room to haul kids and their attendant necessities, and it’s not a minivan or monstrous SUV, which we’ve tried to avoid. But then we took a really close look at one for the first time and fell out of love. The salesman mentioning, almost in his first breath, the “significant depreciation” they suffer the moment you drive them off the lot didn’t really help either. So we kept it in mind but decided to take a drive through the lot of a nearby Honda dealership.

We’ve owned a total of four cars in our dozen-ish years of marriage, and they’ve all been Hondas. So with Honda, we know what we’re getting, and we like it. But we don’t want another Civic, and we don’t really want an Accord. We considered the Element and the CR-V, but then we saw…

The Fit.

The Fit is it! (The only thing I don’t like is “The Fit is go!” But I expect slogans to be stupid.) So unbelievably small (looking) on the outside, but get inside and it’s like the tents at the Quidditch World Cup in Harry Potter and the Goblet of Fire. (OK, maybe I shouldn’t admit how easily that reference comes to mind.) It is truly a marvel of design. There’s just about as much passenger and cargo space in it as in the Forester, but it is small and low and unobtrusive (which is how we like it, contrary to many Americans these days, it would seem). And it gets an extra 10 miles per gallon. Besides, it just looks cooler. I mean, come on. You can take a picture of the Forester in every picturesque city on the Adriatic that you want, that doesn’t make it look any better. (Even if that seaside village seems to be straight out of Project Gotham Racing 2. Am I right?)

So, the search is on. I’ve talked to a few dealerships in the area. Soon the test drives and the purchase and the financing and the payments. And the driving!

Ah crap, I wanted to surprise my parents with it though, like they always do to us when they get a new car. Dad, stop reading this! Too late.

Resizing and regenerating WordPress upload thumbnails

WordPressFor quite some time, I’ve been wishing the thumbnail images WordPress creates when you upload an image were slightly bigger. The function that generates the thumbnails accepts a maximum dimension as an input parameter, but then the value (a paltry 128 pixels) is hardcoded in the script that calls the function, and there’s no way in the standard WordPress configuration to change the value, other than manually editing the admin script where the call is made.

This is easy enough to do, if you know how to find the block of code in question, but it’s wrong wrong wrong in terms of ongoing WordPress updates: when a new version is released and you update your files, the changes you made will be lost.

So the right way to go about this is with a plug-in, and fortunately there is one. It’s simple and it works. Except for the fact that it doesn’t regenerate any of your existing thumbnails.

Maybe there’s something else out there, but I wasn’t able to find one, so I had to resort to rolling my own.

The script is incredibly rudimentary right now. It’s not a plug-in, it doesn’t interface with WordPress admin at all, setting the file path and dimensions require manually editing variable values in the script, there’s no security, etc. It does seem to work though, which is the most important thing. There were a few bugs earlier on that I believe I’ve squashed, but I can’t guarantee there aren’t others, and given how quickly I put it together this afternoon, with kids screaming and car dealerships calling me every 3 minutes (yeah, that’s another blog post), it’s probably not quite as efficient as it could be. (That’s why I cranked up the max_execution_time and memory_limit values. YMMV depending on how many files you have to process.)

As long as you understand that you’re using it at your own risk, feel free to download the script. In order for it to work it should be placed in your wp-admin directory. And remember, it’s not secured at all, so I recommend uploading it, running it, and then deleting it. (Well, now that I think about it, I’m pretty sure including admin.php does automatically provide standard admin security, but don’t quote me on that.)

If I have the time and if anyone actually cares, I’ll update this and turn it into a proper plug-in with all of the attendant niceties. Otherwise… well… never mind!

So long, WordPress!

Well, that’s it. As of last night, the last traces of WordPress on my site are gone.

There’s nothing really wrong with WordPress; in fact, for what it does it’s pretty elegant and flexible. But since, let’s be honest, I’m a geek, and I’m more about building my site than actually creating any meaningful content for it, running it on someone else’s engine is unsatisfying, and almost feels like cheating.

Besides, WordPress (and probably any other third-party tool) will never do everything I want it to, or at least it won’t do it precisely in the way I want it to. And it’s more fun for me to write my own code than to tweak someone else’s. So here we go.