i'm trying to set up a mobile theme for my WordPress site. My desktop version uses themejunkie's weekly theme and my mobile version uses dotmobi theme.
the Dotmobi theme pulls out the first image and displays as a thumbnail where as the weekly theme displays the 'featured image' as a thumbnail or a picture that is defined in a custom field value 'thumb'
How can I make use of this same logic for dotmobi as well?
I tried get_thumbnail()
but that doesn't work. Any help on this please.
I also tried by putting this code into my functions.php
// Get image attachment (sizes: thumbnail, medium, full)
function get_thumbnail($postid=0, $size='full') {
if ($postid<1)
$postid = get_the_ID();
$thumb_key = get_theme_mod('thumb_key');
if($thumb_key)
$thumb_key = $thumb_key;
else
$thumb_key = 'thumb';
$thumb = get_post_meta($postid, $thumb_key, TRUE); // Declare the custom field for the image
if ($thumb != null or $thumb != '') {
return $thumb;
} elseif ($images = get_children(array(
'post_parent' => $postid,
'post_type' => 'attachment',
'numberposts' => '1',
'post_mime_type' => 'image', ))) {
foreach($images as $image) {
$thumbnail=wp_get_attachment_image_src($image->ID, $size);
return $thumbnail[0];
}
} else {
return get_bloginfo ( 'stylesheet_directory' ).'/images/default_thumb.gif';
}
}
and called the same in my index.php
through
<?php echo '<a href="'.get_permalink($post->ID).'" rel="bookmark"><img src="'.get_bloginfo('template_url').'/timthumb.php?src='.get_thumbnail($post->ID, 'full').'&h='.$height.'&w='.$width.'&zc=1" alt="'.get_the_title().'" /></a>' ?>
For some odd reason the thumbnails aren't displaying