Theme Doesn't Address Image Posts
-
Hi
I’m using a premium theme that has a function to retrieve a thumbnail image from a post but it doesn’t work if the post is an image attachment type post. Here is the function:
/* this function gets thumbnail from Post Thumbnail or Custom field or First post image */ if ( ! function_exists( 'get_thumbnail' ) ){ function get_thumbnail($width=100, $height=100, $class='', $alttext='', $titletext='', $fullpath=false, $custom_field='', $post='') { if ( $post == '' ) global $post; global $shortname; $thumb_array['thumb'] = ''; $thumb_array['use_timthumb'] = true; if ($fullpath) $thumb_array['fullpath'] = ''; //full image url for lightbox $new_method = true; if ( has_post_thumbnail( $post->ID ) && !( '' != $custom_field && get_post_meta( $post->ID, $custom_field, true ) ) ) { $thumb_array['use_timthumb'] = false; $et_fullpath = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); $thumb_array['fullpath'] = $et_fullpath[0]; $thumb_array['thumb'] = $thumb_array['fullpath']; } if ($thumb_array['thumb'] == '') { if ($custom_field == '') $thumb_array['thumb'] = esc_attr( get_post_meta($post->ID, 'Thumbnail', $single = true) ); else { $thumb_array['thumb'] = esc_attr( get_post_meta($post->ID, $custom_field, $single = true) ); if ($thumb_array['thumb'] == '') $thumb_array['thumb'] = esc_attr( get_post_meta($post->ID, 'Thumbnail', $single = true) ); } if (($thumb_array['thumb'] == '') && ((et_get_option($shortname.'_grab_image')) == 'on')) { $thumb_array['thumb'] = esc_attr( et_first_image() ); if ( $fullpath ) $thumb_array['fullpath'] = $thumb_array['thumb']; } #if custom field used for small pre-cropped image, open Thumbnail custom field image in lightbox if ($fullpath) { $thumb_array['fullpath'] = $thumb_array['thumb']; if ($custom_field == '') $thumb_array['fullpath'] = apply_filters('et_fullpath', et_path_reltoabs(esc_attr($thumb_array['thumb']))); elseif ( $custom_field <> '' && get_post_meta($post->ID, 'Thumbnail', $single = true) ) $thumb_array['fullpath'] = apply_filters( 'et_fullpath', et_path_reltoabs(esc_attr(get_post_meta($post->ID, 'Thumbnail', $single = true))) ); } } return $thumb_array; } }'
[Please use backticks or the code button for posting code.]Can anyone help me modify it to work with an image attachment post?
Thanks.
Mike
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Theme Doesn't Address Image Posts’ is closed to new replies.