Smokes your problems, coughs fresh air.

Author: Rowan Rodrik (Page 7 of 27)

Rowan is mainly a writer. This blog here is a dumping ground for miscellaneous stuff that he just needs to get out of his head. He is way more passionate about the subjects he writes about on Sapiens Habitat: the connections between humans, each other, and to nature, including their human nature.

If you are dreaming of a holiday in the forests of Drenthe (the Netherlands), look no further than “De Schuilplaats”: a beautiful vacation home, around which Rowan maintains a magnificent ecological garden and a private heather field, brimming with biological diversity.

FlashMQ is a business that offers managed MQTT hosting and other services that Rowan co-founded with Jeroen and Wiebe.

Keeping an unsupported Mint/Ubuntu installation ‘up-to-date’

When a Linux Mint release goes out of support, together with the Ubuntu release on which it is based, the Ubuntu packages become unavailable. This can be annoying for old fossils like me who stubbornly contue to use a release that has gone out of support, as I’m doing with Mint 14 (Nadia), based on Ubuntu 12.10, (Quantal Quetzal). (“Yeah, yeah; I’ll upgrade soon; I promise.”) Luckily, the out-of-support packages remain available in a different location.

So, in /etc/apt/source.list, I could simply replace all instances of archive.ubuntu.com with old-releases.ubuntu.com, so that my /etc/apt/source.list now look like this:

deb http://packages.linuxmint.com/ nadia main upstream import
deb http://old-releases.ubuntu.com/ubuntu/ quantal main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ quantal-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ quantal-security main restricted universe multiverse

G.B.D. Calamari Joomla and phpBB upgrade

As the chairman of G.B.D. Calamari, a Dutch student diving association, it falls to me to upgrade an aging Joomla configuration that is a relict of the last time that the board was chaired by somebody with web-development expertise (Joris van Alphen). This happened to be during a time when Joomla 1.5.20 was cutting-edge. It no longer is, so, although the website still looks nifty enough for this day and age (in my ageing eyes, at least), a software upgrade is long overdue.

[Note that the below is more of a disjointed collection of notes than it is an article of interest to anyone not directly involved with the maintenance of www.gbdcalamari.nl.]

Backup

The first step in any upgrade, of course, is backing up everything. Everything means all the files and the complete database. I did this using the “Export” option in phpmyadmin.

One peculiarity that I noticed during the database backup was that while there there were two MySQL databases — one called calamari_phpbb and one called calamari_site — the one called calamari_phpbb actually contained the tables for both the phpBB forum and the Joomla 1.5 site; calamari_site seemed to be a legacy of an older (custom-written) incarnation of the website.

phpBB.nl upgrade

The phpBB upgrade went surprisingly well. To update phpBB, I used phpbb.nl‘s automatic update packages to update from 3.0.8 to 3.0.12 in 4 steps:

  1. 3.0.8 to 3.0.9 (common.php merged)
  2. 3.0.9 to 3.0.10
  3. 3.0.10 to 3.0.11
  4. 3.0.11 to 3.0.12 (common.php merged again)

One by one, for each of these packages, I

  1. unpacked and uploaded the install dir,
  2. visited http://www.gbdcalamari.nl/phpbb/install/,
  3. updated the database,
  4. downloaded the ‘diff’, and
  5. copied it through WebDAV,
  6. checked if the update was successful and
  7. deleted the install dir.

It was quite fun (albeit a bit cumbersome) to update web software the noob way for a change.

Joomla 1.5.20 to 1.5.26

Joomla 2.5.19 is the current Joomla version (not counting the version 3 branch). The docs on upgrading from 1.5.x to 2.5 mention specifically that it’s a good idea to first upgrade to the latest 1.5.x version. Again, as with phpBB, I played the n00b game and performed the file updates by uploading the files in the the latest 1.5.x patch, overwriting the old Joomla stuff.

Joomla 1.5.26 to 2.5.19

The tricky part was yet to come: the upgrade from one major version to the next, from Joomla 1.5.26 to 2.5.19. The official guide on this process uses the jUpgrade extension. I followed the steps. jUpgrade installed the new version in a jupgrade/ subdirectory in the document root, after which I moved the old installation temporarily into a subdirectory called joomla1.5. (‘Temporarily’ may not be the most accurate qualification; now, five months later, it’s still sitting around as I’m finally polishing the last rough edges left after the upgrade.) With the old installation safed, I moved the Joomla 2.5 files from jupgrade/ to the document root. In this way, I still had access to the old, fully functional site while transitioning the templates and modules, etc.

Joomla components, modules and plug-ins

There are several Joomla components that I had to also upgrade, the most important of which is JFusion, which is necessary for the phpBB integration.

JFusion

It took some tweaking to get JFusion behave as well as it did previously. The following error caused a bit of a headache (and might do so again, during future phpBB updates):

Fatal error: Cannot redeclare utf8_substr() (previously declared
in /home/calamari/public_html/libraries/phputf8/mbstring/core.php:98)
in /home/calamari/public_html/phpbb/includes/utf/utf_tools.php on line 225

The solution was to patch utf_tools.php with a version provided by the JFusion project.

JA Purity

Another process that can be challenging when upgrading between major versions of a CMS is updating the template. The template that has been used by the previous site administrator (JA Purity) seems to be quite popular, however, with a Joomla 2 and 3 version available. Too bad that he did modify it, so that I had to depend om my good old friend that is diff to figure out which changes he made. To be able to more seamlessly upgrade JA Purity in the future, I modified Joris van Alphen’s JA Purity fork to use a Calamari template theme for most of his customizations.

Favicon

I re-enabled the old favicon file, by copying it to the ja_purity_ii/themes/calamari/ directory and copying a modified head.php to a new blocks/ subdirectory for that theme.

File attachments

Migrating file attachment from Joomla 1.5 to 2.5 was non-trivial. Initially, I tried this while running 2.5.7, but the new version of the attachments plugin required 2.5.7 or higher. Besides my initial confusion about how I ended up with Joomla 2.5.7 instead of 2.5.19, following the cumbersome instructions in the project‘s upgrade manual worked out well.

Event Manager

Eventually, Joomla Event Manager is set to replace the EvenList component by Schlu that Joris had used for the Joomla 1.5 incarnation of the Calamari website. For now, though, Schlu’s EventList component will do. Data migration only required copying the MySQL table rows from the Joomla 1.5 prefixed tables (“jos_”) to the Joomla 2.5 prefixed tables (“j25_”):

INSERT INTO j25_* SELECT * FROM jos_*;
INSERT INTO j25_eventlist_categories SELECT * FROM jos_eventlist_categories;
INSERT INTO j25_eventlist_events SELECT * FROM jos_eventlist_events;
INSERT INTO j25_eventlist_groupmembers SELECT * FROM jos_eventlist_groupmembers;
INSERT INTO j25_eventlist_groups SELECT * FROM jos_eventlist_groups;
INSERT INTO j25_eventlist_register SELECT * FROM jos_eventlist_register;
INSERT INTO j25_eventlist_settings SELECT * FROM jos_eventlist_settings;
INSERT INTO j25_eventlist_venues SELECT * FROM jos_eventlist_venues;

Contact form

To upgrade the ALFcontact component
again only, the factory contacts had to be replaced with the old Calamari contacts, after downloading and installing the new version:

DELETE FROM j25_alfcontact;
INSERT INTO j25_alfcontact SELECT * FROM jos_alfcontact;

Polls

The Joomla 1.5 website used mod_poll for some fun (but mostly useless polls), a module which was removed somewhere during the further development of the 1.5 branch. I found no ready replacement which could import the old mod_poll content, so I decided to not install a new module.

Picasa integration

For the continued use use wgPicassa, the most important step is to upload years worth of photos to Picasa, which was supposedly inconvenient, because the Picasa account was said to be linked to Joris’ private Google Account. I thought I’d thus have to create a new Picasa account, linked to an @gbdcalamari.nl email address and ask him to re-upload all the photo’s in his account. Luckily, it turned out that the Picassa account was already associated with an @gbdcalamari.nl email address. So, after resetting the password using that email adress, we can now finally update the gallery.

Slideshow on public homepage

A slideshow with promotional pictures was originally displayed on the home page for non-logged in visitors (using the Unite Nivo Slider extension). It took me some trouble to find out how to display this module before the main content in JA Purity. In fact, that was the only place where I couldn’t position anything. All I could find were clumsy work-arounds, until I stumbled upon the existance of “mass positions” in the JA developer guide.

Joomla 2.5.19 to 2.5.24

I left the upgrade process were it was on Mach 31 of this year, finally continuing the process this August. In the meantime, the Joomla 2.5 branch has arrived at version 2.5.24. Luckily for me, it’s much easier to update an existing 2.5.x installation. After making a fresh backup of everything, I unpacked the archive remotely, after which I updated the database. That was it.

Left to do

  • Cleanup excess JUpgrade table.
  • Get rid of the cpanel thingy in the header
  • Move font size control from cpanel thingy to header?
  • Restore search in header
  • Reinstall XMap extension
  • Rename database to avoid future confusion

Readline shortcuts: Ctrl-s and XOFF

And another contribution to my list of Readline keyboard shortcuts. This time it’s a note by Joo Matos, pointing me to problems with the Ctrl-s shortcut. (It acts as a flow control character that pauses transmission on some terminals.)

He adds that:

It’s easy to disable special treatment of Ctrl-s by the terminal with stty -ixon.

Remember also that, if you accidentally hit Ctrl-s, it’s easy to undo the effects with Ctrl-q.

Thanks Joo!

Increasing the number of reps on my pull-ups

Update June 16, 2023, regarding my misuse of the N-word. I’ve come to regret my use of the N-word in the below. I was, ten years ago, quite ignorant of how it could and could not be used. As a Dutch customer weaned on an intellectual diet of popular American music (rap music in particular), I was under the impression that saying “nigger” in the context were I used it was a legitimate way to express admiration for the prowess of certain black men. I was wrong, and could have known that I was wrong if I had spent more time educating myself rather than just being brainwashed by American mass media.

I’m growing increasingly frustrated with my inability to increase the number of pull-ups I can do in one set. And, after so many years, I’m still not even close to doing a single one-hand pull-up or one of those muscle-ups all the niggers on YouTube seem to be doing these days. That’s why I’m going to let one of those black dudes guide me and my puny, little white frame:

That’s Ed from Barstarzz demonstrating a program developed by Major Charles Lewis Armstrong.

The program

I’m going to try the Armstrong workout program [PDF mirror from www.lamarineofficerprograms.com] for this month.

Every day morning routine

During my morning routine, I’ll perform 3 sets of push-ups until exhaustion. The program doesn’t mention this, but I’m going to use a different push-up technique every day.

Progress on the program

I started yesterday with Day 2 of the program so that I can follow it from Monday to Friday. Here I’ll track my progress during the weeks to come.

Pull-up progress
Day 1 Day 2 Day 3 Day 4 Day 5
Description: 5 sets of max. reps Piramid sets (1 rep, 10 secs rest, 2 reps, 20 secs rest, etc. until failure; rest 60 sec and repeat last no. of reps same no. reps for 3*3 sets (3 different techniques; 60 sec. intervals) Same as day 3 + 1 rep/set Repeat hardest routine of the week
Week 1: Didn’t start yet 7 reps max 7 reps 8 reps 8 reps
Week 2: Pieterpad 7 reps max 8 reps (too optimistic) Left for Zeeland on Thu-night
Week 3: 12+8+6+7+8 7 reps max asleep 9*8 reps some reps
Week 4: drinking and partying too tired 9*8 reps
Week 5: Kampkater depressed depressed 9*10 reps 2*7+3*5 reps explosive pull-ups (chest to bar)
Week 6: 15+14+12+10+15 reps 10 reps max 9*11 reps
Week 7: 20+20+15+12+12 reps 9*11 reps 3*12 reps
Week 8: 12+19+10+10+9 reps 12 reps max
Push-up progress
Day 1 Day 2 Day 3 Day 4 Day 5
Description: Diamond push-ups Small push-ups Wide push-ups One-armed push-ups Hindu push-ups
Week 1: I only started with the routine on Day 2 50+20+20+10 reps 3*15 reps 50+60+20 reps
Week 2: 50+50+30 reps ?+?+? reps ?+?+? reps 3*10 reps Zeeland
Week 3: 80+40+40 reps 3*50 reps 50+50+30 reps 3*15 reps 3*50 reps
Week 4: 50+70+70 reps 3*70 reps 120(140?)+100+70 reps 20 reps
Week 5: 30+20+20 reps 3*70 reps
Week 6: 80+80 reps 100+70+50 reps 3*30 reps
Week 7: 100+70+100 reps 3*80 reps 10+20+30 reps ? reps
Week 8: 100 reps 110+100 reps 15+20 reps 100 reps
Week 9: 120+100 reps 3*50 reps 30+50+50 reps [pansy-ass sore knuckles] 100+ reps

Converting a Subversion repository to Git

I just used the instructions in this article by John Albin to archive an old svn project on my private machine.

A shell summary (see the John’s article for details):

svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt
 
vim authors-transform.txt
# Make changes
 
git svn clone [SVN repo URL] --no-metadata -A authors-transform.txt --stdlayout ~/temp
 ~/temp
git svn show-ignore > .gitignore
git add .gitignore
git commit -m 'Convert svn:ignore properties to .gitignore.'
 
git init --bare ~/new-bare.git ~/new-bare.git
git symbolic-ref HEAD refs/heads/trunk
 ~/temp
git remote add bare ~/new-bare.git
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare
 ~
rm -rf ~/temp
 ~/new-bare.git
git branch -m trunk master
 ~/new-bare.git
git for-each-ref --format='%(refname)' refs/heads/tags |
cut -d / -f 4 | ref
  git tag "$ref" "refs/heads/tags/$ref";
  git branch -D "tags/$ref";

John has also put all this into a number of scripts published on GitHub.

HP Officejet 6600 in Ubuntu (derivates)

A reminder which printer type I have to select when I reinstall my mom’s Officejet in Linux: HP Officejet 6600 E-all-in-one Printer – h711a.

At the time of installation, last week, the printer wasn’t supported by the version of hplip that’s shipped with Mint Linux 13 (Maya), so I had to download a newer version. This probably won’t be an issue with the next reinstall, which hopefully won’t be soon; gladly, release 13 is an LTS.

Styling visited links for payformystay.com

I wanted to change the text of visited links on payformystay.com, using CSS. In the offer summary, I wanted to change the link text “Check it out!” with “Check it out again!” after the user had indeed checked out the offer.

A payformystay.com offer

An example of a payformystay.com offer where I'd want to replace the 'Check it out!' link text.

I thought I could use something as simple as:

<a href="/offer/34234-title">
  <span class="unvisited-label">Check it out!</span>
  <span class="visited-label">Check it out again!</span>
</a>

together with…

a:link span.visited-label,
a:visited span.unvisited-label {
 :;
}
 
a:link span.unvisited-label,
a:visited span.visited-label {
 :;
}

Or, even simpler:

a:visited {
 : 'Check it out again!';
}

However, I bumped into a glass wall while trying to get this to work. Apparently, browser manufacturers have been removing features to increase security. The problem, apparently, is that as a third party you could find out if somebody has been visiting a particular URL by linking to, styling :visited links and then querying the computed styles of the link. To avoid this, getComputedStyle() in the major browsers now lies and most style rules are ignored within rules applied to the :visited pseudo-class.

I’m still considering a work-around with JavaScript (setting a visited class) on the anchors, because I hate to let a good darling die.

Exemplary web design: danwebb.net

While investigating fragment identifiers and hashbangs for payformystay.com quite a while back, I came across this article by Dan Web, when I noticed that I really, really liked the design of danwebb.net:

Screengrab of danwebb.net

Screengrab of danwebb.net

It’s not often that I find myself liking a dark design, but this one’s much nicer and even more readable than most light designs. The contrast is good. It’s clean. It’s simple. I just really like it.

I’m finishing this post today, because I just noticed that a secret project that I’m currently working on might have its design unconsciously inspired by this or something similar.

Aihato WordPress maintenance notes

According to Brian Kernighan, “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you’re as clever as you can be when you write it, how will you ever debug it?” With that in mind I’m re-exposing myself to the spaghetti that is the Aihato WordPress code base.

My last comment on that project stems from December of 2010, although there have been some minor code updates in the meantime—not all of them by me—mostly having to do with the look and feel.

During my Christmas break, I visited the Ytec office to meet with their sysadmin. He made the old Subversion repository available to me again (although, internally, they’ve gone over to Bazaar) and created a new development version of the site (which hadn’t been moved along with the move of the production version to a new server). After some changes to my Makefile, I’m now able to do the whole development/production dance again, and I’ve just tested this by successfully upgrading to WordPress 3.5.1 (all the way from 3.0.5). Yes, this is quite a simple affair, if your setup is 1337:

Upgrading WordPress

I really like it better when the WordPress factory stuff lives in its own directory. I like this better even than using vendor branches to keep track of what’s mine and what’s WordPress’s. Let me show you why (and yes, I could have turned this into a proper script, if I wanted to):

# Get into my working dir
www.aihato.nl
 
# Add the new WP version to the externals
svn propget svn:externals . > /tmp/wp-ext 'wp-3.5.1 http://core.svn.wordpress.org/tags/3.5.1/' >> /tmp/wp-ext
svn update
svn propset svn:externals --file /tmp/wp-ext
 
rm wp # The symbolic link pointing to the old wp-3.0.5
ln -s wp-3.5.1 wp
 
make update-development # to test if the upgrade will fuck up anything major
make deploy-production # because it works
 
svn ci -m "Upgraded WP from wp-3.0.5 to wp-3.5.1."

Rewrite problems after upgrade

Of course, the upgrade had to cause some trouble. This particular trouble was caused by some code in my theme’s functions.php that really belonged in a plugin. I basically made a rogue call to $wp_rewrite->flush_rules(); which caused the rewrite rules to either lack the ones concerning my custom category base (‘/categorie’) or those concerning my custom rewrite endpoints.

To fix this I created an exceedingly simple plugin with just the following code:

add_action('init', 'gallery_endpoint_initialize');
 
register_activation_hook( __FILE__, function() {
  global $wp_rewrite;
 
  add_rewrite_endpoint('gallery', EP_PERMALINK | EP_PAGES);
  $wp_rewrite->flush_rules();
});
 
function gallery_endpoint_initialize() {
  add_rewrite_endpoint('gallery', EP_PERMALINK | EP_PAGES);
  add_filter('query_vars', 'aihato_queryvars');
}
 
function aihato_queryvars($qvars) {
  $qvars[] = 'gallery';
  return $qvars;
}

Thoughts on custom post types for fighter profiles

I commented on custom post types before, in the section on fighter profiles in the extensive summary of the whole development process, and in a comment in my development notes.

The custom post type for fighter profiles that I started implementing as a plugin is still quite high on my feature wishlist. The complex dance with page parent, page template and custom fields has proven to be quite difficult for the guys.

At the time, a real showstopper “bug” was that the featured image box wasn’t displayed with the post type. Now, it took me approximately five minutes to find out that I should have simply added the custom post type to the add_theme_support() call in my theme’s functions.php:

add_theme_support('post-thumbnails', array('post', 'page', 'aihato_fighter'));

Another problem “was that clicking the Insert image button replaced the current page with the upload dialog instead of loading it in a modal dialog through AJAX.” This seems to be resolved in the new WordPress, so postponing the custom post type stuff until it had stabilized a bit in the future has proven to be an excellent strategy. Apparently, that future has arrived.

I do wonder: if I implement the custom post type for fighter profiles now, how do I convert my existing page content to the custom post type? Could I just change the post_type field in the database after adding the necessary function calls to register this new type?

Also, I’m thinking of turning some of the custom fields not just into fancy boxes in the post edit GUI, but into proper taxonomies. This might complicate migration even further, so it’s probably the wisest course to do this thing in phases:

  1. Implement the custom post types with integrated support in the GUI for the custom fields that will remain custom fields under the hood.
  2. Maybe migrate some custom fields (such as fighter discipline) to proper taxonomies.
  3. Modify the theme to use the new custom post type instead of the old pages.
  4. Integrate the fight record stuff with the aihato-events stuff.

The process of moving to fighter profiles to their own custom post type deserves a dedicated post, but this’ll have to wait until I actually continue this process.

Thoughts on improving the photo gallery

There are some annoying bugs in the photo gallery. I want to start out by upgrading all the relevant JavaScript libraries that I used to see how far that will bring me.

Performance-wise, there’s also some low-hanging fruit. Photo’s are often uploaded in high resolution. Instead of forbidding this, I want this to be performance neutral in its effect by, instead of using the full version of the image in many places (such as the gallery, using a huge-ass thumbnail that serves as the “enlarged” version when you click pictures in the gallery and such.

Thoughts on improving the video gallery

With regards to the video gallery, it has turned out the YouTube support is not sufficient. I will have to find a way to base the gallery on all oEmbed links. I have, since initial deployment, already added embed (not oEmbed) support for fightstartv.com:

wp_embed_register_handler('fightstartv', '|http://www\.fightstartv\.com/videos/([a-zA-Z0-9-_]+)/|', 'embed_handler_fightstartv');
 
function embed_handler_fightstartv($matches, $attr, $url, $rawattr) {
  $fstv_html = file_get_contents($url);
  $fstv_html_matches = array();
  preg_match('|"(/upload/[^"/]+.mp4)".*"image": "([^"]+)"|', $fstv_html, $fstv_html_matches);
  $fstv_mp4_url = 'http://www.fightstartv.com' . $fstv_html_matches[1];
  $fstv_image_url = $fstv_html_matches[2];
 
  $embed = '<embed src="http://www.fightstartv.com/wp-content/plugins/vipers-video-quicktags/resources/jw-flv-player/player.swf" height="300" width="600" bgcolor="0x000000" allowscriptaccess="always" allowfullscreen="true" flashvars="file='.urlencode($fstv_mp4_url).'&skin=http%3A%2F%2Fwww.fightstartv.com%2Fwp-content%2Fplugins%2Fvipers-video-quicktags%2Fresources%2Fjw-flv-player%2Fskins%2Fmodieus.swf&volume=100&bufferlength=3&backcolor=0x000000&duration=-1&frontcolor=0xffffff&lightcolor=0xffffff&screencolor=0x000000&autostart=false&image='.urlencode($fstv_image_url).'&ltas.cc=zerfildkisjwvgk&ltas.height=268&ltas.width=700&ltas.y=0&ltas.visible=true&ltas.x=0&adtvideo.height=268&adtvideo.y=0&adtvideo.position=over&adtvideo.width=700&adtvideo.visible=true&adtvideo.x=0&adtvideo.config=http%3A%2F%2Fwww.fightstartv.com%2Fmy_config.xml& adttext.height=268& adttext.width=700& adttext.y=0& adttext.visible=true& adttext.x=0&adttext.y=0&adttext.x=0&adttext.height=268&adttext.visible=true&adttext.config=http%3A%2F%2Fwww.fightstartv.com%2Fadttext.php&adttext.width=600&plugins=hd-2,viral-1,ltas,adtvideo, http://plugins.longtailvideo.com/5/flow/flow-2.swf, adttext,adttext"/>';
    echo $match[0];
 
  return apply_filters('embed_fightstartv', $embed, $matches, $attr, $url, $rawattr);
}

But these videos show up as just links in the film gallery instead of sporting the fancy FancyBox popup. Luckily, thumbnails do work, but more due to a quirk than by actual design. 🙁 This is going to take some time to cleanup, because most of the code concerned is terribly YouTube-centric by design.

Latest video on the homepage

The homepage features a block with the latest video. From my previous notes on this subject: “[… T]o show the latest video on the homepage, I just perform a search for posts which contain a YouTube URL. Then I parse the content a bit, and include the YouTube ID in my own low-res embed code. (The latest video area on the homepage is smaller than the default embed created by WordPress.)”

As of late, no video had been showing there, making me suspect—No I’m not telling you that. It’s actually too embarrassing!

Block with(out) latest video on the home page

Block with(out) latest video on the home page

This had everything to do with a missing hyphen character in the video id character class in the YouTube URL matching regexp within the scraping function:

preg_match('|http://www.youtube.com/watch\?v=([-a-zA-Z0-9]+)|', // better
preg_match('|http://www.youtube.com/watch\?v=([a-zA-Z0-9]+)|', // worse 

With the hyphen added:

Block with latest video on the home page

Block with latest video on the home page

Making post thumbnails crop from the top

WordPress hard crops uploaded images to match the post thumbnail size (set with set_post_thumbnail_size()) and the other alternative image sizes (added through add_image_size()). It does this from the center. This gives horrible results in the common case that a person does not happen to be decapitated and holding his or her head in his or her hands:

Aihato fighter profiles with cut-off heads

In the image editor, there is the ability to edit the thumbnail separately from the actual image, allowing you to manually crop the thumbnail, but this is cumbersome and only allows you to choose between applying the changes to all image sizes, just the thumbnail or to everything but the thumbnail, and I happen to not be using the thumbnail for the fighter profiles.

Basically, what I want is for WordPress to hard crop from the top instead of from the middle of the photo. And this would be an ok default for all photos. I truly don’t get why this isn’t configurable by default.

I found someone suggesting to change image_resize_dimensions() in wp-includes/media.php, because, at the time that he encountered the problem, there were apparently no plugin hooks available. There is a filter now, since WP version 3.4, called “image_resize_dimensions”. A quick Googling for this function/filter name reveals that, apparently, the Codex now even has a ready-to-go recipe to crop thumbnails by keeping the top of the image, instead of the default center.

With this code up and running in a plugin called ‘top-crop’, I consider this problem fixed. No more looking at beheaded fighters and no need for my users to muck around with the image editor (which wouldn’t work anyway because I use to many different image sizes).

My trusty old regenerate-thumbnails and the new AJAX Thumbnail Rebuild are doing their job after me chasing ghosts for hours because of a silent file permission problem on the development web server.

Aihato fighter profiles with heads

Aihato fighter profiles with heads

Relief and anticipation

In retrospect, digging back into the spaghetti isn’t as bad as it could have been, partly because I spent an extraordinary amount of time on documenting all the bumps in the road before. After reacquainting myself, I’m actually less intimidated by the prospect of upping the awesomeness of www.aihato.nl than I was when I actually delivered the product, which goes entirely against the saying at the beginning of this article. Either I’m smarter now than I was a couple of years ago, or I exercised sufficient constraint in introducing complexities (although (mostly well-documented) idiosyncrasies abound).

« Older posts Newer posts »

© 2024 BigSmoke

Theme by Anders NorenUp ↑