Christian Bolstad

Some kind of web stuff, yeah.

Add a default fallback for get_post_thumbnail / featured image

30 September, 2012 By Christian Bolstad

Since WordPress doesn’t have any support for a “default thumbnail” and there isn’t any filters that works directly on get_post_thumbnail(),  the_post_thumbnail(), get_post_thumbnail_id(), get_the_post_thumbnail(), etc – we need to hook the filter get_post_metadata.

/*
* Fall back to a hard coded default thumbnail if a thumbnail doesn't already exist
*/
function custom_filter_get_post_metadata($metadata, $object_id, $meta_key, $single)
{

if(isset($meta_key) && '_thumbnail_id' === $meta_key)
{
//Temporarily remove filter to fetch the real data, since it's not sent as a parameter to this filter
remove_filter('get_post_metadata', 'custom_filter_get_post_metadata', true, 4);

// Get real thumbnail id
$existing_thumbnail = get_post_meta($object_id,'_thumbnail_id',true);

// Set it to a fallback ID if it doesn't already exist
if (empty($existing_thumbnail)) $result = 3372; << CHANGE THIS ID TO A ATTACHMENT ID!!!

// Re-enable the filter
add_filter('get_post_metadata', 'custom_filter_get_post_metadata', true, 4);

if(!empty($result))
return $result;
}

return $metadata;
}
add_filter('get_post_metadata', 'custom_filter_get_post_metadata', true, 4);

Filed Under: wordpress Tagged With: default thumbnail, get_post_thumbnail, wordpress

IRC – now even more legit for work

8 November, 2011 By Christian Bolstad

No news for us nerds: IRC is one of the best protocols for communication. There is clients for every OS, in all kind of flavors. And with help of an bouncer or using screen you will never lose track of the conversation after being AFK.  [Read more…]

Filed Under: work vs leisure Tagged With: irc

Almost snow

9 November, 2010 By Christian Bolstad

Yesterdays cold disappeared as the rain came in a sticky form of something that with a big generosity could be called snow. The lousy weather was an great excuse to sleep in… The day has been filled with som adminstrative duties, WordPress (me and Ann is co-hacking a multi-language-multi-site setup for Bonnier Business Publishing) and SEO (working on a long tail strategy with Flygstolen). And yeah, during lunch I finally took myself the time to write a post on Iphone 24.

Filed Under: Egoshots

Chilly day and storage problems

8 November, 2010 By Christian Bolstad

The morning started a bit earlier than usually but it took exceptional long time to arrive to the office today. Just as I was about to leave home the monitoring alerts started beeping in the phone. Several customer sites suddenly went offline as one of Swedens biggest web hosts, Binero, experienced problems with its SAN causing almost four hours of downtime. When everything finally was up and running I reported to owners of the websites and arrived to KB5 a few minutes after 2 pm.

Filed Under: Egoshots Tagged With: binero, netapp

Sunday November 7

7 November, 2010 By Christian Bolstad

Slow day at the office trying to upgrade a wordpress plugin to make it comptabile with version 3. Had a strange potato and salomon dinner with Anders Färdigh before he left for some late sunday night adventures.

Filed Under: Egoshots Tagged With: Procrastination

  • 1
  • 2
  • 3
  • …
  • 5
  • Next Page »