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

by Linus Neumann on August 4, 2010

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.


[…] If you decide to publish a post without title, it will be un-flattr-able using the flattr-Plugin for WordPress, as the flattr-API cannot (yet?) deal with an empty title. Possible solutions equal those I described for the empty-excerpt-problem. […]

by Another little “fix” for Wordpress’ flattr-Plugin (untitled posts) | Linus-Neumann.de on 11. August 2010 at 18:27. #

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.

by sorin7486 on 21. September 2010 at 16:57. #

[…] Ok so it took me a while to figure this one out… I installed the nice flattr widget for WordPress and I configured it to work with my account just like another page I have. Then I post something just to see if it works and surprise surprise it doesn’t. So I check everything and recheck, I even submit the “content” as a thing on the flattr site and still nothing. So I start googling and I find this. […]

by Flattr can’t do less than 5 chars in title | 7486 on 21. September 2010 at 19:03. #

Leave your comment


Required. Not published.

If you have one.