Web Design and Build

jQuery UI slider on touchscreen devices Last updated:13 May 2015

I’ve been meaning to have a look at updating my vertical scrollbar code so it works on a touchscreen. Finally found time this weekend to have a look…with rather limited results. I created three versions of the page, one using touchpunch, one with touchpunch improved, and one with a basic mapping of touch events to mouse events.

Device OS Browser TP TP improved Mapping
Versus tablet Android 4.0.4 Android browser Fails Fails Fails
Samsung Galaxy Ace Android 2.3.6 Android browser Fails Fails Fails
Apple iPhone 3G iOS 4.2.1 Safari Works Works Works
Samsung Galaxy Ace 2 Android 4.1.2 Android browser Works Works Works
Apple iPad Mini 1 iOS 8 Safari Works Works Works
Nokia Lumia 635 Windows 8.1 IE11 Works Works but with errors Works

Conclusion so far…Touchpunch works on newer devices only. If you have access to a different device, test the different pages and let me know the result.

imagejpeg issues with PHP 5.4 Last updated:27 November 2014

Came across an interesting little issue this afternoon while debugging an issue with a very old osCommerce installation. This particular site uses an on the fly product thumb generator (product_thumb.php) which worked fine with PHP 5.3 but failed with PHP 5.4.

After a bit of digging I tracked the issue to this line in the original code:

imagejpeg($src, '', 100);

In PHP 5.4 this fails, and needs to be replaced with:

imagejpeg($src, NULL, 100);

Perhaps this will save someone a bit of time. I didn’t find this problem noted elsewhere.

Making this site responsive Last updated:21 June 2014

I’ve been thinking about making this site responsive for some time, but never quite got round to it, in part because only about 1% of the traffic is from mobile devices, but I have finally got around to it. Now this site has grown up over the last, errr, five or six years, and I was expecting it be a bit of a nightmare.

Not so! The css file is pretty large anyway, but to date I have added only 94 css statements to media queries for small screens, and I think I’m nearly there, the only major challenge left is the photography slideshows. I have done this backwards according to conventional wisdom, in that I’ve started with a desktop site and reverse-engineered a mobile site. I can’t quite get my mind around why that piece of wisdom anyway… Just for comparison, bootstrap.css has more than 5000 entries.

Ordnance Survey maps in WordPress Last updated:16 June 2014

We’ve just finished another site which embeds OS Openspace maps into WordPress pages: Dartefacts. This uses a custom post type to record the grid reference of an object, which is then displayed on a home page map showing all the items, custom taxonomy pages and search results. This works really well with several hundred items (so far) displaying on the home page, and is fully responsive as well.

OS map showing multiple points and a pop up balloon linking to a page

We’re really pleased with this site (and so is the client!). This builds on our earlier site Rombalds Riding which displays gpx routes as well as points.

Getting the lowest level category (or custom taxonomy) for a WordPress post Last updated:6 June 2014

Working on a client project which applies a hierarchical custom taxonomy to a custom post type I needed to find the lowest level set for the post. Assuming that there is only one hierarchy applied to the post the following does the trick, for categories (running on the single post page):

$categories = get_categories();
$parents = array();
	foreach ($categories as $category){
		$ids[] = $category->term_id;//read the category ids into an array
		if ($category->parent) $parents[] = $category->parent;//read the parent ids into an array
$low_categories =  array_diff ($ids,$parents);//get the ids which are not parents
$lowest_category = array_shift($low_categories);//read the first id (just in case there's more than one)

If you’re working with a custom taxonomy called, say, ‘classification’ then this becomes:

$post_classifications = get_the_terms($get_the_ID,'classification');
	foreach ($post_classifications as $post_classification){
		$ids[] = $post_classification->term_id;
		if ($post_classification->parent) $parents[] = $post_classification->parent;
$low_class =  array_diff ($ids,$parents);
$classification = array_shift($low_class);

Hope this helps someone else…