function kingsize_portfolio_custom_columns($column)
{
    global $post;
    switch ($column) {
        case "portfolio_categories":
            echo get_the_term_list($post->ID, __('portfolio-category'), '', ', ', '');
            break;
        case "portfolio_image":
            $image_portfolio = get_post_meta($post->ID, 'upload_image', true);
            $video_thumb_image = get_post_meta($post->ID, 'upload_image_thumb', true);
            if ($image_portfolio != '') {
                $overview_image = $image_portfolio;
            } elseif ($video_thumb_image != '') {
                $overview_image = $video_thumb_image;
            } else {
                $overview_image = kingsize_get_the_post_thumbnail_url($post->ID);
            }
            if ($overview_image != '') {
                $url_post_img = wm_image_resize('50', '50', $overview_image);
                echo '<img src="' . $url_post_img . '" width="50" height="50" alt="" />';
            }
            break;
    }
}
function kingsize_thumb_box($postid, $str_crop = '')
{
    global $no_of_page_columns;
    $lightbox = "true";
    $image_portfolio = get_post_meta($postid, 'upload_image', true);
    $video_thumb_image = get_post_meta($postid, 'upload_image_thumb', true);
    $video = get_post_meta($postid, 'kingsize_video_url', true);
    $height = get_post_meta($postid, 'kingsize_video_height', true);
    $embed = trim(get_post_meta($postid, 'kingsize_embed_code', true));
    if ($height == '') {
        $lightbox_height = 350;
    } else {
        $lightbox_height = $height + 20;
    }
    if ($image_portfolio != '') {
        $overview_image = $image_portfolio;
    } elseif ($video_thumb_image != '') {
        $overview_image = $video_thumb_image;
    } else {
        $overview_image = kingsize_get_the_post_thumbnail_url($postid);
    }
    //Added in V 4.1.3 to exclude the featured image into portfolio lightbox
    $exclude_featured = false;
    if (get_post_meta($postid, 'kingsize_exclude_portfolio_thumb', true) == 1) {
        $exclude_featured = true;
    } else {
        $exclude_featured = false;
    }
    #### Getting the attachments image items for portfoio V4 ####
    $args = array('post_type' => 'attachment', 'post_parent' => $postid, 'orderby' => "menu_order ID", 'order' => ASC);
    $attachments = get_children($args);
    ##### Getting the number of columns	#####
    if (empty($no_of_page_columns)) {
        $no_of_page_columns = "2columns";
    }
    if ($no_of_page_columns == "2columns") {
        $url_post_img = wm_image_resize('330', '220', $overview_image, $str_crop);
    } elseif ($no_of_page_columns == "3columns") {
        $url_post_img = wm_image_resize('220', '140', $overview_image, $str_crop);
    } elseif ($no_of_page_columns == "4columns") {
        $url_post_img = wm_image_resize('160', '110', $overview_image, $str_crop);
    } elseif ($no_of_page_columns == "grid") {
        $url_post_img = wm_image_resize('112', '112', $overview_image, $str_crop);
    }
    ###### End number of columns ######
    #### Getting the thumbnail ####
    if ($overview_image == '') {
        $thumb = get_the_post_thumbnail($postid, 'thumbnail-post');
    } else {
        $thumb = '<img src="' . $url_post_img . '"  title="' . get_the_title() . '"/>';
    }
    ###### SETTING of the portfolio thumbnail link #########
    if (get_post_meta($postid, 'portfolios_thumbnail_link', true) != '') {
        $lightbox = 'false';
        $permalink = get_post_meta($postid, 'portfolios_thumbnail_link', true);
    } else {
        $lightbox = 'true';
        $permalink = get_permalink($postid);
    }
    #### SETTING of Lightbox on Portfolio write up panel #######
    if (get_post_meta($postid, 'portfolios_lightbox_disable', true) == 'disable') {
        $lightbox = 'false';
    } else {
        $lightbox = 'true';
    }
    ####### CHECKING of lightbox effect is enabled or not ######
    if ($lightbox == 'true') {
        if ($embed != '') {
            // we get the width & height
            preg_match('/width="([0-9]+)"/', $embed, $matches_width);
            preg_match('/height="([0-9]+)"/', $embed, $matches_height);
            $height = $matches_height[1];
            $width = $matches_width[1];
            $output = '<a rel="prettyPhoto[gallery-' . $postid . ']" title="' . get_the_title($postid) . '" href="' . get_template_directory_uri() . '/lib/portfolio/kingsize-portfolio-video.php?id=' . $postid . '&iframe=true&width=' . $width . '&height=' . $height . '" class="video">' . $thumb . '</a>';
        } elseif ($video != '' && $embed == '') {
            $output = '<a rel="prettyPhoto[gallery-' . $postid . ']" title="' . get_the_title($postid) . '" href="' . $video . '" class="video">' . $thumb . '</a>';
        } else {
            ####### Getting the file name ########
            //patched in 4.1 thumbnail not showing in lightbox correct size
            $attachment_id = kingsize_get_attachment_id_from_url($overview_image);
            $image_attributes = wp_get_attachment_image_src($attachment_id, "full");
            if ($image_attributes["0"] != '') {
                $image_path = $image_attributes["0"];
            } else {
                $image_path = $overview_image;
            }
            //Added in V 4.1.3 to exclude the portfolio thumb
            if ($exclude_featured == true) {
                if ($attachments) {
                    $i = 0;
                    $featured_exclude_img_fst = "";
                    $featured_exclude_attachID_fst = "";
                    foreach ($attachments as $attachment) {
                        if ($attachment_id != $attachment->ID) {
                            if ($i == 0) {
                                //Image URL
                                $featured_exclude_attachID_fst = $attachment->ID;
                                $featured_exclude_img_fst = wp_get_attachment_url($attachment->ID);
                                //Title and Description
                                if (!empty($attachment->post_content)) {
                                    $post_title = $attachment->post_title . "<p>" . strip_tags($attachment->post_content) . "</p>";
                                } else {
                                    $post_title = $attachment->post_title;
                                }
                                if (get_post_meta($attachment->ID, '_wp_attachment_image_alt', true) == "") {
                                    $post_alt = $attachment->post_title;
                                } else {
                                    $post_alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                                }
                            }
                            $i++;
                        }
                    }
                    $output = '<a rel="prettyPhoto[gallery-' . $postid . ']" title="' . $post_title . '" href="' . $featured_exclude_img_fst . '" class="image">' . $thumb . '</a>';
                }
            } else {
                $attachment = get_post($attachment_id);
                //Title and Description
                if (!empty($attachment->post_content)) {
                    $post_title = $attachment->post_title . "<p>" . strip_tags($attachment->post_content) . "</p>";
                } else {
                    $post_title = $attachment->post_title;
                }
                if (get_post_meta($attachment->ID, '_wp_attachment_image_alt', true) == "") {
                    $post_alt = $attachment->post_title;
                } else {
                    $post_alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                }
                $output = '<a rel="prettyPhoto[gallery-' . $postid . ']" title="' . $post_title . '" href="' . $image_path . '" class="image">' . $thumb . '</a>';
            }
        }
        #### Getting the attachments image items for portfoio V4 ####
        if ($attachments) {
            $i = 0;
            foreach ($attachments as $attachment) {
                if ($exclude_featured == true) {
                    if ($featured_exclude_attachID_fst != $attachment->ID && $attachment_id != $attachment->ID) {
                        //Title and Description
                        if (!empty($attachment->post_content)) {
                            $post_title = $attachment->post_title . "<p>" . strip_tags($attachment->post_content) . "</p>";
                        } else {
                            $post_title = $attachment->post_title;
                        }
                        if (get_post_meta($attachment->ID, '_wp_attachment_image_alt', true) == "") {
                            $post_alt = $attachment->post_title;
                        } else {
                            $post_alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                        }
                        $url_post_img = wm_image_resize('330', '220', wp_get_attachment_url($attachment->ID), $str_crop);
                        $output .= '<ul style="display:none;"><li><a href="' . wp_get_attachment_url($attachment->ID) . '" title="' . $post_title . '" rel="prettyPhoto[gallery-' . $postid . ']"><img  src="' . $url_post_img . '"  title="' . $post_title . '" /></a></li></ul>';
                    }
                } else {
                    //exclude has been not checked for feature image
                    if ($attachment_id != $attachment->ID) {
                        //Title and Description
                        if (!empty($attachment->post_content)) {
                            $post_title = $attachment->post_title . "<p>" . strip_tags($attachment->post_content) . "</p>";
                        } else {
                            $post_title = $attachment->post_title;
                        }
                        if (get_post_meta($attachment->ID, '_wp_attachment_image_alt', true) == "") {
                            $post_alt = $attachment->post_title;
                        } else {
                            $post_alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                        }
                        $url_post_img = wm_image_resize('330', '220', wp_get_attachment_url($attachment->ID), $str_crop);
                        $output .= '<ul style="display:none;"><li><a href="' . wp_get_attachment_url($attachment->ID) . '" title="' . $post_title . '" rel="prettyPhoto[gallery-' . $postid . ']"><img  src="' . $url_post_img . '"  title="' . $post_title . '" /></a></li></ul>';
                    }
                }
            }
        }
        #### End attachments image items for portfoio V4 #######
    } else {
        $output = '<a title="' . get_the_title($postid) . '" href="' . $permalink . '" class="custom-port">' . $thumb . '</a>';
    }
    echo $output;
}