a little bugfix for the flattr-plugin for WordPress (Errors occuring for image or video only posts)

Update: Here’s another little fix for untitled posts

So, I decided to install the flattr-plugin for WordPress.
In settings, I decided my general category for posts is written/text – because it usually is.

I’ve been running this blog for longer than flattr exists, so a total of 323 posts was now equipped with flattr-Buttons. Among these were posts that did not contain any (or just very short) text, but only videos or images. For these, the flattr-Button looked like this:


not good. Fix needed.

This “Error” was due to the labeling as “text”, which causes the plugin to try to create an excerpt for flattr. This, of course, fails. The ‘fix’ for that would be labelling image- or video-only posts appropriately. I am too lazy for that, though. I promise to label my future posts correctly, but I will not work through all my past posts.

So, here’s the fix. In case the excerpt is shorter than 10 characters, this will fill in “This post is textless.” as the excerpt, and the button renders just fine, as you can see here.

Download flattr.php fixed Version
Download flattr Plugin patch
(cd to directory flattr, then do ‘cat /Path/to/flattr.patch  | patch -p1

or do it manually:

1. Open flattr. php (Version: 0.9.11)
2. in line 283 (just before ‘return $excerpt;’), enter:

// If excerpt can not be created because there is no text content
if (strlen($excerpt) < 10)
{
$excerpt = "This post ist textless.";
}

Note: This is of course not perfectly the intended use, as flattr.com apparently wants quite detailed information on what people are looking at and flattr’ing. You have to decide, how much information they need. Apart from that, I believe this little patch is still useful if for any other reason the creation of an excerpt fails, and adds to the stability and fail-safe-ness of the plugin.

3 thoughts on “a little bugfix for the flattr-plugin for WordPress (Errors occuring for image or video only posts)

  1. Pingback: Another little “fix” for Wordpress’ flattr-Plugin (untitled posts) | Linus-Neumann.de

  2. sorin7486

    Hey thanks … Took me a while to figure I can’t have the title of the post smaller than 5 characters … like “test” :)). I’m not going to change the code but I got rid of the error.

    Reply
  3. Pingback: Flattr can’t do less than 5 chars in title | 7486

Leave a Reply

Your email address will not be published. Required fields are marked *