</div> </div> </section> <section class="products container"> <div class="row"> <?php $cat = get_categories(array('type' => 'catalog')); $current_cat = get_query_var('name'); $items = get_posts(array('posts_per_page' => -1, 'post_type' => 'catalog', 'tax_query' => array(array('taxonomy' => 'catalog', 'field' => 'slug', 'terms' => array($current_cat))))); foreach ($items as $item) { $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($item->ID), 'medium'); ?> <a class="<?php if (is_big($post)) { ?> col-xs-3 products__product--big <?php } else { ?> col-xs-3 <?php } ?> products__product" href="/catalog/<?php echo $current_cat; ?> /<?php echo $item->post_name; ?> ">
/** * FUNCTION USED TO GET THUMBNAIL * @param ARRAY video_details, or videoid will also work */ function get_thumb($vdetails, $num = 'default', $multi = false, $count = false, $return_full_path = true, $return_big = true, $size = false) { //echo $size; global $db, $Cbucket, $myquery; $num = $num ? $num : 'default'; #checking what kind of input we have if (is_array($vdetails)) { if (empty($vdetails['title'])) { #check for videoid if (empty($vdetails['videoid']) && empty($vdetails['vid']) && empty($vdetails['videokey'])) { if ($multi) { return $dthumb[0] = default_thumb(); } return default_thumb(); } else { if (!empty($vdetails['videoid'])) { $vid = $vdetails['videoid']; } elseif (!empty($vdetails['vid'])) { $vid = $vdetails['vid']; } elseif (!empty($vdetails['videokey'])) { $vid = $vdetails['videokey']; } else { if ($multi) { return $dthumb[0] = default_thumb(); } return default_thumb(); } } } } else { if (is_numeric($vdetails)) { $vid = $vdetails; } else { if ($multi) { return $dthumb[0] = default_thumb(); } return default_thumb(); } } #checking if we have vid , so fetch the details if (!empty($vid)) { $vdetails = get_video_details($vid); } if (empty($vdetails['title'])) { if ($multi) { return default_thumb(); } return default_thumb(); } #Checking if there is any custom function for if (count($Cbucket->custom_get_thumb_funcs) > 0) { foreach ($Cbucket->custom_get_thumb_funcs as $funcs) { //Merging inputs $in_array = array('num' => $num, 'multi' => $multi, 'count' => $count, 'return_full_path' => $return_full_path, 'return_big' => $return_big, 'size' => $size); if (!empty($vdetails['files_thumbs_path']) && $funcs == 'server_thumb') { $funcs = "ms_server_thumb"; } if (function_exists($funcs)) { $func_returned = $funcs($vdetails, $in_array); if ($func_returned) { return $func_returned; } } } } // echo "hooooo"; #get all possible thumbs of video $thumbDir = isset($vdetails['file_directory']) && $vdetails['file_directory'] ? $vdetails['file_directory'] : ""; if (!isset($vdetails['file_directory'])) { $justDate = explode(" ", $vdetails['date_added']); $thumbDir = implode("/", explode("-", array_shift($justDate))); } if (substr($thumbDir, strlen($thumbDir) - 1) !== "/") { $thumbDir .= "/"; } //$justDate = explode(" ", $vdetails['date_added']); //$dateAdded = implode("/", explode("-", array_shift($justDate))); $file_dir = ""; if (isset($vdetails['file_name']) && $thumbDir) { $file_dir = "/" . $thumbDir; } $vid_thumbs = glob(THUMBS_DIR . "/" . $file_dir . $vdetails['file_name'] . "*"); #replace Dir with URL if (is_array($vid_thumbs)) { foreach ($vid_thumbs as $thumb) { if (file_exists($thumb) && filesize($thumb) > 0) { $thumb_parts = explode('/', $thumb); $thumb_file = $thumb_parts[count($thumb_parts) - 1]; if (!is_big($thumb_file) || $return_big) { if ($return_full_path) { $thumbs[] = THUMBS_URL . '/' . $thumbDir . $thumb_file; } else { $thumbs[] = $thumb_file; } } } elseif (file_exists($thumb)) { unlink($thumb); } } } if (count($thumbs) == 0) { if ($count) { return count($thumbs); } if ($multi) { return $dthumb[0] = default_thumb(); } return default_thumb(); } else { if ($multi) { return $thumbs; } if ($count) { return count($thumbs); } //Now checking for thumb if ($num == 'default') { $num = $vdetails['default_thumb']; } if ($num == 'big' || $size == 'big') { $num = 'big-' . $vdetails['default_thumb']; if (!file_exists(THUMBS_DIR . '/' . $vdetails['file_name'] . '-' . $num . '.jpg')) { $num = 'big'; } } $default_thumb = array_find($vdetails['file_name'] . '-' . $num, $thumbs); if (!empty($default_thumb)) { return $default_thumb; } return $thumbs[0]; } }
function server_thumb($vdetails, $array) { global $__resize_thumbs; if (!$__resize_thumbs) { return; } $w = DEFAULT_WIDTH; $h = DEFAULT_HEIGHT; list($width, $height) = explode('x', $array['size']); if (isset($width) && is_numeric($width) && isset($height) && is_numeric($height)) { $w = $width; $h = $height; } if ($array['num'] == 'big' || $array['size'] == 'big') { $w = 320; $h = 250; } else { if ($array['num'] == 'medium' || $array['size'] == 'medium') { $w = 160; $h = 90; } else { if ($array['num'] == 'small' || $array['size'] == 'small') { $w = 120; $h = 60; } } } $tim_postfix = '&type=photos&h=' . $h . '&w=' . $w . '&zc=1'; global $baseurl; $timthumb_path = CB_SERVER_THUMB_URL . '/timthumb.php?src='; #get all possible thumbs of video $thumbDir = isset($vdetails['file_directory']) && $vdetails['file_directory'] ? $vdetails['file_directory'] : ""; if (!isset($vdetails['file_directory'])) { $justDate = explode(" ", $vdetails['date_added']); $thumbDir = implode("/", explode("-", array_shift($justDate))); } if (substr($thumbDir, strlen($thumbDir) - 1) !== "/") { $thumbDir .= "/"; } //$justDate = explode(" ", $vdetails['date_added']); //$dateAdded = implode("/", explode("-", array_shift($justDate))); $file_dir = ""; if (isset($vdetails['file_name']) && $thumbDir) { $file_dir = "/" . $thumbDir; } $vid_thumbs = glob(THUMBS_DIR . "/" . $file_dir . $vdetails['file_name'] . "*"); #replace Dir with URL if (is_array($vid_thumbs)) { foreach ($vid_thumbs as $thumb) { if (file_exists($thumb) && filesize($thumb) > 0) { $thumb_parts = explode('/', $thumb); $thumb_file = $thumb_parts[count($thumb_parts) - 1]; if (!is_big($thumb_file) || $array['return_big']) { if ($array['return_full_path']) { $thumbs[] = $timthumb_path . $thumb_file . '&directory=thumbs/' . $thumbDir . $tim_postfix; } else { $thumbs[] = $timthumb_path . $thumb_file . '&directory=thumbs/' . $tim_postfix; } } } elseif (file_exists($thumb)) { unlink($thumb); } } } if (count($thumbs) == 0) { $get_default_thumb = explode('/', default_thumb()); $d_thumb = end($get_default_thumb); if ($array['count']) { return count($thumbs); } if ($array['multi']) { return $dthumb[0] = $timthumb_path . $d_thumb . '&directory=thumbs/' . $tim_postfix; } return $timthumb_path . $d_thumb . '&directory=thumbs/' . $tim_postfix; } else { if ($array['multi']) { return $thumbs; } if ($array['count']) { return count($thumbs); } //Now checking for thumb if ($array['num'] == 'default') { $num = $vdetails['default_thumb']; } if ($array['num'] == 'big' || $array['size'] == 'big') { $num = 'big-' . $vdetails['default_thumb']; if (!file_exists(THUMBS_DIR . '/' . $vdetails['file_name'] . '-' . $num . '.jpg')) { $num = 'big'; } } $default_thumb = array_find($vdetails['file_name'] . '-' . $num, $thumbs); if (!empty($default_thumb)) { return $default_thumb; } return $thumbs[0]; } }
/** * Get thumbnails of a video * * This function will get all video thumbnails * and list them in array, you can either get single * thumb or number or size. This function has few limitations * that we will try to cover in upcoming updates. * * @since 2.x * @uses default_thumb(); * @uses MyQuery->get_video_details(); * * @param $vdetails ARRAY video details, array('videod','title'...) or it can be just STRING videoid * @param $num STRING number of thumb , if you want to get thumb-2 , you will set 2, default value is 'default' which return 1 * @param $multi BOOLEAN weather to return ALL thumbnails in array or just single thumb * @param $count BOOLEAN just count thumbs or not, if set to true, function will return number of thumb INT only * @param $return_full_path BOOLEAN if set to true, thumb will be return along with THUMBS_URL e.g http://cb/thumb/file-1.jpg * if set to false, it will return file-1.jpg * @param $return_big BOOLEAN weather to return BIG thumbnail or not, if set true, it will return file-big.jpg * * @since 2.6 * @param $size STRING dimension of thumb, it can be 120x90, 320x240, it was introduced in 2.6 to get more thumbs * using the same funcion. * @return STRING video thumbnail with/without path or ARRAY list of video thumbs or INT just number of thumbs * */ function get_thumb($vdetails, $num = 'default', $multi = false, $count = false, $return_full_path = true, $return_big = true, $size = NULL) { global $db, $Cbucket, $myquery, $cbvid; if (!is_array($vdetails)) { $vdetails = $myquery->get_video_details($vdetails); } $extras = $cbvid->get_video_extras($vdetails['videoid'], $vdetails['extras']); $thumbs = $extras['thumbs']; $vdetails['thumbs'] = $thumbs; if ($vdetails['thumbs']) { if ($return_full_path) { $folder = ''; $folder = $vdetails['file_directory']; if ($folder) { $folder .= '/'; } if (!isset($vdetails['files_thumbs_path'])) { $path = $vdetails['files_thumbs_path'] . '/' . $folder; } else { $path = THUMBS_URL . '/' . $folder; } } else { $path = ''; } if (!is_array($vdetails['thumbs'])) { $thumbs = json_decode($vdetails['thumbs'], true); } else { $thumbs = $vdetails['thumbs']; } $_thumbs = array(); if ($thumbs) { foreach ($thumbs as $the_size => $thumbs) { foreach ($thumbs as $thumb) { $_thumbs[$the_size][] = $path . $thumb; } } $thumbs = $_thumbs; } $thumb_size = get_size_by_name($size); if (!$thumb_size) { $thumb_size = $size; } if (!is_numeric($num) || $num < 1) { $num = 1; } $img = $thumbs[$thumb_size][$num - 1]; if (!$img) { $img = $thumbs[get_size_by_name('default')][0]; } if (!$img) { if (is_array($thumbs)) { foreach ($thumbs as $thumb) { $img = $thumb[0]; break; } } } if ($img) { if ($count) { return count($thumbs[$thumb_size]); } if ($multi) { if ($multi == 'all') { return $thumbs; } else { return $thumbs[$thumb_size]; } } return $img; } } $num = $num ? $num : 'default'; //checking what kind of input we have if (is_array($vdetails)) { if (empty($vdetails['title'])) { //check for videoid if (empty($vdetails['videoid']) && empty($vdetails['vid']) && empty($vdetails['videokey'])) { if ($multi) { return $dthumb[0] = default_thumb(); } return default_thumb(); } else { if (!empty($vdetails['videoid'])) { $vid = $vdetails['videoid']; } elseif (!empty($vdetails['vid'])) { $vid = $vdetails['vid']; } elseif (!empty($vdetails['videokey'])) { $vid = $vdetails['videokey']; } else { if ($multi) { return $dthumb[0] = default_thumb(); } return default_thumb(); } } } } else { if (is_numeric($vdetails)) { $vid = $vdetails; } else { if ($multi) { return $dthumb[0] = default_thumb(); } return default_thumb(); } } //checking if we have vid , so fetch the details if (!empty($vid)) { $vdetails = $myquery->get_video_details($vid); } if (empty($vdetails['title'])) { if ($multi) { return default_thumb(); } return default_thumb(); } //Checking if there is any custom function for if (count($Cbucket->custom_get_thumb_funcs) > 0) { foreach ($Cbucket->custom_get_thumb_funcs as $funcs) { //Merging inputs $in_array = array('num' => $num, 'size' => $size, 'multi' => $multi, 'count' => $count, 'return_full_path' => $return_full_path, 'return_big' => $return_big); if (function_exists($funcs)) { $func_returned = $funcs($vdetails, $in_array); if ($func_returned) { return $func_returned; } } } } #get all possible thumbs of video if ($vdetails['file_name']) { $vid_thumbs = glob(THUMBS_DIR . "/" . $vdetails['file_name'] . "*"); } #replace Dir with URL if (is_array($vid_thumbs)) { foreach ($vid_thumbs as $thumb) { if (file_exists($thumb) && filesize($thumb) > 0) { $thumb_parts = explode('/', $thumb); $thumb_file = $thumb_parts[count($thumb_parts) - 1]; if (!is_big($thumb_file) || $return_big) { if ($return_full_path) { $thumbs[] = THUMBS_URL . '/' . $thumb_file; } else { $thumbs[] = $thumb_file; } } } elseif (file_exists($thumb)) { unlink($thumb); } } } if (count($thumbs) == 0) { if ($count) { return count($thumbs); } if ($multi) { return $dthumb[0] = default_thumb(); } return default_thumb(); } else { if ($multi) { return $thumbs; } if ($count) { return count($thumbs); } //Now checking for thumb if ($num == 'default') { $num = $vdetails['default_thumb']; } if ($num == 'big' || $size == 'big') { $num = 'big-' . $vdetails['default_thumb']; if (!file_exists(THUMBS_DIR . '/' . $vdetails['file_name'] . '-' . $num . '.jpg')) { $num = 'big'; } } $default_thumb = array_find($vdetails['file_name'] . '-' . $num, $thumbs); if (!empty($default_thumb)) { return $default_thumb; } return $thumbs[0]; } }
<section class="small-catalog"> <div class="container"> <div class="row small-catalog__inner"> <?php $args = array('sort_order' => 'ASC', 'sort_column' => 'menu_order', 'post_type' => 'page', 'include' => '5,19,21,23,26,28,30,32,34,36,38,40', 'post_status' => 'publish'); $categories = get_pages($args); foreach ($categories as $category) { $thumb_url = wp_make_link_relative(wp_get_attachment_url(get_post_thumbnail_id($category->ID))); $thumb = ltrim($thumb_url, '/'); if (is_big($category->ID)) { $icon_class = 'small-catalog__icon--big'; } else { $icon_class = 'small-catalog__icon--small'; } ?> <a class="small-catalog__item <?php if ($post === $category->ID) { echo "current"; } ?> " href="<?php echo get_permalink($category->ID); ?> "> <div class="small-catalog__inner"> <div class="small-catalog__icon <?php echo $icon_class; ?> "> <?php include $thumb;