term_id, 'thumbnail_id', TRUE ); if ( $term_thumbnail_id ) { $_post_preview = wp_get_attachment_image( $term_thumbnail_id, $thumbnail_size ); } } // Generate media preview if ( $_post_preview == '' AND $media_preview AND ! post_password_required() ) { if ( get_post_type() == 'product' ) { // for products with gallery $postID = get_the_ID(); $product_images = get_post_meta( $postID, '_product_image_gallery', TRUE ); if ( $product_images ) { $slider_shortcode = '[us_image_slider ids="' . get_post_thumbnail_id() . ',' . $product_images . '" img_size="' . $thumbnail_size . '" arrows="hover"]'; $_post_preview = do_shortcode( $slider_shortcode ); } } else { // for posts with Video, Audio, Gallery formats $us_post_slider_size = $thumbnail_size; $the_content = get_the_content(); $_post_preview = us_get_post_preview( $the_content ); } if ( $_post_preview != '' ) { $classes .= ' media_preview'; // add CSS class for media preview $link_atts = ''; // remove link for media preview } } // Output image of attachment post type if ( $_post_preview == '' AND get_post_type() == 'attachment' ) { $_post_preview = wp_get_attachment_image( get_the_ID(), $thumbnail_size ); } // Output Featured image if ( $_post_preview == '' AND has_post_thumbnail() ) { $_post_preview = get_the_post_thumbnail( get_the_ID(), $thumbnail_size ); } // Output the first image from the content of Gallery format if ( $_post_preview == '' AND get_post_format() == 'gallery' ) { $the_content = get_the_content(); if ( preg_match( '~\[us_gallery.+?\]|\[us_image_slider.+?\]|\[gallery.+?\]~', $the_content, $matches ) ) { $gallery = preg_replace( '~(vc_gallery|us_gallery|gallery)~', 'us_image_slider', $matches[0] ); preg_match( '~\[us_image_slider(.+?)\]~', $gallery, $matches2 ); $shortcode_atts = shortcode_parse_atts( $matches2[1] ); if ( ! empty( $shortcode_atts['ids'] ) ) { $ids = explode( ',', $shortcode_atts['ids'] ); if ( count( $ids ) > 0 ) { $_post_preview = wp_get_attachment_image( $ids[0], $thumbnail_size ); } } } } // Output placeholder if enabled if ( $_post_preview == '' AND $placeholder ) { $classes .= ' with_placeholder'; // Use WooCommerce placeholder if enabled if ( ( $us_elm_context == 'grid_term' OR get_post_type() == 'product' ) AND function_exists( 'wc_placeholder_img_src' ) ) { $_post_preview = ''; } else { $_post_preview = '
'; } } // Don't output the element without any content if ( $_post_preview == '' ) { return; } $output = '
'; if ( ! empty( $link_atts ) ) { $output .= ''; } $output .= $_post_preview; if ( ! empty( $link_atts ) ) { $output .= ''; } $output .= '
'; echo $output;