Video Test

This post is just a test post playing with embedding video with the HTML 5 video element. First, I’m going to try just dragging in a video, and see what WordPress gives me, then I’ll probably end up hand coding it.

This video was shot during my 2012 hot air balloon ride, with my iPhone. One problem I’ve had using iPhone video is that it often comes out upside down. It looks OK in Aperture, and in the QuickTime player, but when I go to transcode it into other formats, it comes out upside down. I discovered tonight the trick is to open it in QuickTime player, and export it.

Continue reading

Comments on WordPress Image Pages, Revisited

Back in January, I posted a solution to a the problem of comment forms on image attachment pages remaining available even after comments on the parent post had closed, based on a solution by Anthony Hortin, of Maddison Designs. I was getting spam from the images on my first gallery page.

The solution I posted back then was to make the include of comments_template() conditional on the parent post’s comments being open. This worked, I stopped getting comments on old images. The code looked like this:

The original fix:

Change this:
<?php comments_template(); ?>
To this:
<?php if (comments_open($post->post_parent)) {
// Only show the Comments Form if the parent post has comments open
comments_template();
} ?>

Unfortunately, the fix has a side effect: comments posted to an image during the “comments open” period also go away when the comments close. At the beginning of the month I posted a picture of some stuff I saw on the Charles that I couldn’t identify; a nice lady answered me, but her answer vanished when the comments closed.

It turns out the comments_template() function also outputs existing comments, so what you really want to do is still include comments_template(), but somehow, tell it comments are closed.

Fortunately, the function that returns the flag that indicates whether comments are open respects a filter, ‘comments_open’, so it became simply a matter of figuring out how to add that filter.

My first attempts to do so crashed. My function that tried to set the flag was trying to call comment_open() with the parent post, and crashed. Then I tried only applying the filter if the parent post’s comments were closed, using a function that simply returns false. It feels kludgy, but it does work.

The Revised Fix:

Change this:
<?php comments_template(); ?>
To this:
<?php
function close_image_post_comments() {return false;}

if (!comments_open($post->post_parent)) {
/* Only show the Comments Form if the parent post has comments open
by adding a filter to pass false to comments_open() */

add_filter( 'comments_open', 'close_image_post_comments', 10, 2 );
}
comments_template(); //bring in the comment output
?>

This feels a little kludgy to me– I’d rather have the decision making in the function rather than the calling code, but it does work, and at this point, I’m not handy enough with PHP to figure out what I was doing wrong in the earlier version of my function.

 

Controlling Comments on Image Pages in Twenty Eleven

I’ve been having problems with comment spam on the site. Strangely enough, they always seemed to come from one of the images on my very first gallery post, even though the post itself  doesn’t have a comment form (I have comments set to automatically close after three days).

Unwanted Comments on Image Attachment Pages

It turns out that image attachment pages don’t respect the site’s comment settings, at least not in the Twenty Eleven theme that I’m using as a parent. After another spam comment the other day, I found that Anthony Hortin, of Maddison Designs had solved the problem for the previous default WordPress theme, Twenty Ten. The solution involves adding a check to see if the attachment’s parent post still allows comments.

The Fix:

Change this:
<?php comments_template(); ?>
To this:
<?php if (comments_open($post->post_parent)) {
// Only show the Comments Form if the parent post has comments open
comments_template();
} ?>

The code is the same as Anthony’s; the only difference is that in Twenty Eleven, the file to modify is image.php, not attachment.php as it is in Twenty Ten. Since I’m already running a child theme, I made a copy of image.php and put it in my child theme folder, rather than modifying the parent theme file. This is the recommended way of making changes; but it does mean that if WordPress makes a change to the parent file, I won’t see the update. Hopefully, they’ll address the issue at some point.

Update, June 2012:

I’ve discovered there’s a significant drawback to this fix: Any comments posted during the open period are also hidden when comments closed. See this post for a further discussion and revised fix.