/** * Returns correct thumbnail HTML for the portfolio posts * * @since 2.0.0 */ function wpex_get_portfolio_post_thumbnail($args = array()) { // Define thumbnail args $defaults = array('size' => 'portfolio_post', 'class' => 'portfolio-single-media-img', 'alt' => wpex_get_esc_title(), 'schema_markup' => true); // Parse arguments $args = wp_parse_args($args, $defaults); // Return thumbanil return wpex_get_post_thumbnail(apply_filters('wpex_get_portfolio_post_thumbnail_args', $args)); }
<?php /** * Single Custom Post Type Media * * @package Total WordPress theme * @subpackage Partials * @version 3.3.0 */ // Exit if accessed directly if (!defined('ABSPATH')) { exit; } // Thumbnail args $args = apply_filters('wpex_' . get_post_type() . '_single_thumbnail_args', array('size' => 'full', 'alt' => wpex_get_esc_title(), 'schema_markup' => true)); // Get thumbnail $thumbnail = wpex_get_post_thumbnail($args); // Display featured image if ($thumbnail) { ?> <div id="post-media" class="wpex-clr"> <?php echo $thumbnail; ?> </div><!-- #post-media --> <?php }
<div class="wpex-carousel-slide wpex-clr<?php if ($entry_css) { echo ' ' . $entry_css; } ?> "> <?php // Display media if ('true' == $media && has_post_thumbnail()) { ?> <?php // Image html $img_html = wpex_get_post_thumbnail(array('size' => $img_size, 'crop' => $img_crop, 'width' => $img_width, 'height' => $img_height, 'alt' => wpex_get_esc_title())); ?> <div class="<?php echo $media_classes; ?> "> <?php // No links if ('none' == $thumbnail_link) { ?> <?php echo $img_html; ?>
/** * Tweaks the default WP Gallery Output * * @since 1.0.0 */ public static function output($output, $attr) { // Main Variables global $post, $wp_locale, $instance; $instance++; static $instance = 0; $output = ''; // Sanitize orderby statement if (isset($attr['orderby'])) { $attr['orderby'] = sanitize_sql_orderby($attr['orderby']); if (!$attr['orderby']) { unset($attr['orderby']); } } // Get shortcode attributes extract(shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'columns' => 3, 'include' => '', 'exclude' => '', 'img_height' => '', 'img_width' => '', 'size' => '', 'crop' => ''), $attr)); // Get post ID $id = intval($id); if ('RAND' == $order) { $orderby = 'none'; } if (!empty($include)) { $include = preg_replace('/[^0-9,]+/', '', $include); $_attachments = get_posts(array('include' => $include, 'post_status' => '', 'inherit' => '', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); $attachments = array(); foreach ($_attachments as $key => $val) { $attachments[$val->ID] = $_attachments[$key]; } } elseif (!empty($exclude)) { $exclude = preg_replace('/[^0-9,]+/', '', $exclude); $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } else { $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby)); } if (empty($attachments)) { return ''; } if (is_feed()) { $output = "\n"; $size = $size ? $size : 'thumbnail'; foreach ($attachments as $attachment_id => $attachment) { $output .= wp_get_attachment_link($attachment_id, $size, true) . "\n"; } return $output; } // Get columns # $columns = intval($columns); // Set cropping sizes if ($columns > 1) { $img_width = $img_width ? $img_width : wpex_get_mod('gallery_image_width'); $img_height = $img_height ? $img_height : wpex_get_mod('gallery_image_height'); } // Sanitize Data $size = $size ? $size : 'large'; $size = $img_width || $img_height ? 'wpex_custom' : $size; $crop = $crop ? $crop : 'center-center'; // Float $float = is_rtl() ? 'right' : 'left'; // Load lightbox skin stylesheet wpex_enqueue_ilightbox_skin(); // Begin output $output .= '<div id="gallery-' . $instance . '" class="wpex-gallery wpex-row lightbox-group clr">'; // Begin Loop $count = 0; foreach ($attachments as $attachment_id => $attachment) { // Increase counter for clearing floats $count++; // Attachment Vars $attachment_data = wpex_get_attachment_data($attachment_id); $alt = $attachment_data['alt']; $caption = $attachment_data['caption']; $video = $attachment_data['video']; $lightbox_url = $video ? $video : wpex_get_lightbox_image($attachment_id); // Generate the image HTMl $img_html = wpex_get_post_thumbnail(array('attachment' => $attachment_id, 'size' => $size, 'width' => $img_width, 'height' => $img_height, 'crop' => $crop)); // Add data attributes for lightbox if ($video) { $lightbox_data = ' data-options="thumbnail: \'' . wpex_get_lightbox_image($attachment_id) . '\', width:1920, height:1080"'; } else { $lightbox_data = ' data-type="image"'; } // Start Gallery Item $output .= '<figure class="gallery-item ' . wpex_grid_class($columns) . ' col col-' . $count . '">'; // Display image $output .= '<a href="' . $lightbox_url . '" title="' . wp_strip_all_tags($caption) . '" class="wpex-lightbox-group-item"' . $lightbox_data . '>'; $output .= $img_html; $output .= '</a>'; // Display Caption if (trim($attachment->post_excerpt)) { if (wpex_is_front_end_composer()) { $output .= '<div class="gallery-caption">' . wptexturize($attachment->post_excerpt) . '</div>'; } else { $output .= '<figcaption class="gallery-caption">' . wptexturize($attachment->post_excerpt) . '</figcaption>'; } } // Close gallery item div $output .= "</figure>"; // Set vars to remove margin on last item of each row and clear floats if ($count == $columns) { $count = '0'; } } // Close gallery div $output .= "</div>\n"; return $output; }
/** * Returns correct thumbnail HTML for the staff posts * * @since 2.0.0 */ function wpex_get_staff_post_thumbnail() { return wpex_get_post_thumbnail(apply_filters('wpex_get_staff_post_thumbnail_args', array('size' => 'staff_post', 'class' => 'staff-single-media-img', 'alt' => wpex_get_esc_title(), 'schema_markup' => true))); }
// Add featured image to the array $secondary_attachment_url = ''; if (!empty($attachment_ids)) { $attachment_ids = array_unique($attachment_ids); // remove duplicate images if (count($attachment_ids) > '1') { if ($attachment_ids['0'] !== $attachment) { $secondary_img_id = $attachment_ids['0']; } elseif ($attachment_ids['1'] !== $attachment) { $secondary_img_id = $attachment_ids['1']; } } } // Get secondary image output if (!empty($secondary_img_id)) { $secondary_image = wpex_get_post_thumbnail(array('attachment' => $secondary_img_id, 'size' => 'shop_catalog', 'class' => 'woo-entry-image-secondary')); } else { $secondary_image = false; } // Return thumbnail if ($main_image && $secondary_image) { ?> <div class="woo-entry-image-swap clr"> <?php echo $main_image; ?> <?php echo $secondary_image; ?> </div><!-- .woo-entry-image-swap -->
* @package Total WordPress theme * @subpackage Partials * @version 3.0.0 */ // Exit if accessed directly if (!defined('ABSPATH')) { exit; } // Disable embeds $show_embeds = apply_filters('wpex_related_blog_posts_embeds', false); // Check if experts are enabled $has_excerpt = wpex_get_mod('blog_related_excerpt', true); // Get post format $format = get_post_format(); // Get featured image $thumbnail = wpex_get_post_thumbnail(array('size' => 'blog_related')); // Add classes $classes = array('related-post', 'clr', 'nr-col'); $classes[] = wpex_grid_class($wpex_columns); $classes[] = 'col-' . $wpex_count; ?> <article <?php post_class($classes); ?> > <?php // Display post video if ($show_embeds && 'video' == $format && ($video = wpex_get_post_video_html())) { ?>
/** * Alter the cart item thumbnail size * * @since 3.0.0 */ public static function cart_item_thumbnail($thumb, $cart_item, $cart_item_key) { if (!empty($cart_item['variation_id']) && ($thumbnail = get_post_thumbnail_id($cart_item['variation_id']))) { return wpex_get_post_thumbnail(array('size' => 'shop_thumbnail', 'attachment' => $thumbnail)); } elseif (isset($cart_item['product_id']) && ($thumbnail = get_post_thumbnail_id($cart_item['product_id']))) { return wpex_get_post_thumbnail(array('size' => 'shop_thumbnail', 'attachment' => $thumbnail)); } else { return wc_placeholder_img(); } }
<?php // Loop through attachments foreach ($attachments as $attachment => $custom_link) { ?> <?php // Define main vars $custom_link = '#' != $custom_link ? $custom_link : ''; $attachment_link = get_post_meta($attachment, '_wp_attachment_url', true); $attachment_data = wpex_get_attachment_data($attachment); $caption_type = $caption_type ? $caption_type : 'caption'; $caption_output = $attachment_data[$caption_type]; $attachment_video = wp_oembed_get($attachment_data['video']); $attachment_video = wpex_add_sp_video_to_oembed($attachment_video); // Generate img HTML $attachment_img = wpex_get_post_thumbnail(array('attachment' => $attachment, 'size' => $img_size, 'crop' => $img_crop, 'width' => $img_width, 'height' => $img_height, 'alt' => $attachment_data['alt'])); ?> <div class="wpex-slider-slide sp-slide"> <div class="wpex-slider-media"> <?php // Check if the current attachment has a video if ($attachment_video) { ?> <div class="wpex-slider-video responsive-video-wrap"> <?php echo $attachment_video; ?>
/** * Alters post author bio data based on staff item relations * * @since 2.1.0 */ public static function post_author_bio_data($data) { $relations = get_option('wpex_staff_users_relations'); $staff_member_id = isset($relations[$data['post_author']]) ? $relations[$data['post_author']] : ''; if ($staff_member_id) { $data['author_name'] = get_the_title($staff_member_id); $data['posts_url'] = get_the_permalink($staff_member_id); $featured_image = wpex_get_post_thumbnail(array('attachment' => get_post_thumbnail_id($staff_member_id), 'size' => 'wpex_custom', 'width' => $data['avatar_size'], 'height' => $data['avatar_size'], 'alt' => $data['author_name'])); if ($featured_image) { $data['avatar'] = $featured_image; } } return $data; }
/** * Returns the blog post thumbnail * * @since 1.0.0 */ function wpex_get_blog_post_thumbnail($args = '') { // If args isn't array then it's the attachment if (!is_array($args) && !empty($args)) { $args = array('attachment' => $args, 'alt' => wpex_get_esc_title(), 'width' => '', 'height' => '', 'class' => '', 'schema_markup' => false); } // Defaults $defaults = array('size' => 'blog_post', 'schema_markup' => true); // Parse arguments $args = wp_parse_args($args, $defaults); // Apply filter to args $args = apply_filters('wpex_blog_entry_thumbnail_args', $args); // Generate thumbnail $thumbnail = wpex_get_post_thumbnail($args); // Apply filters for child theming return apply_filters('wpex_blog_post_thumbnail', $thumbnail); }
$wpex_query->the_post(); // Create new post object. $post = new stdClass(); // Get attachment ID $post->id = get_the_ID(); // Attachment VARS $post->data = wpex_get_attachment_data($post->id); $post->link = $post->data['url']; $post->alt = esc_attr($post->data['alt']); $post->title_display = false; // Pluck array to see if item has custom link $post->url = $images_links_array[$post->id]; // Validate URl $post->url = '#' !== $post->url ? $post->url : ''; // Set image HTML since we'll use it a lot later on $post->thumbnail = wpex_get_post_thumbnail(array('size' => $img_size, 'attachment' => $post->id, 'alt' => $post->alt, 'width' => $img_width, 'height' => $img_height, 'crop' => $img_crop)); ?> <div class="id-<?php echo $post->id . ' ' . $entry_classes; ?> col-<?php echo $count; ?> "> <figure class="<?php echo $figure_classes; ?> ">
/** * Returns correct thumbnail HTML for the testimonials entries * * @since 2.0.0 */ function wpex_get_testimonials_entry_thumbnail() { return wpex_get_post_thumbnail(array('size' => 'testimonials_entry', 'class' => 'testimonials-entry-img', 'alt' => wpex_get_esc_title())); }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ function widget($args, $instance) { // Set vars $title = isset($instance['title']) ? apply_filters('widget_title', $instance['title']) : __('Recent Posts', 'wpex'); $number = isset($instance['number']) ? $instance['number'] : '3'; $style = isset($instance['style']) ? $instance['style'] : 'default'; $order = isset($instance['order']) ? $instance['order'] : ''; $date = isset($instance['date']) ? $instance['date'] : ''; $post_type = isset($instance['post_type']) ? $instance['post_type'] : ''; $taxonomy = isset($instance['taxonomy']) ? $instance['taxonomy'] : ''; $terms = isset($instance['terms']) ? $instance['terms'] : ''; $img_hover = isset($instance['img_hover']) ? $instance['img_hover'] : ''; $img_size = isset($instance['img_size']) ? $instance['img_size'] : 'wpex_custom'; $img_height = !empty($instance['img_height']) ? intval($instance['img_height']) : ''; $img_width = !empty($instance['img_width']) ? intval($instance['img_width']) : ''; $img_size = $img_width || $img_height ? 'wpex_custom' : $img_size; $exclude = is_singular() ? array(get_the_ID()) : NULL; // Sanitize terms if ($terms) { $terms = str_replace(', ', ',', $terms); $terms = explode(',', $terms); } // Before widget WP hook echo $args['before_widget']; // Display title if defined if ($title) { echo $args['before_title'] . $title . $args['after_title']; } ?> <ul class="wpex-widget-recent-posts clr style-<?php echo $style; ?> "> <?php // Query args $query_args = array('post_type' => $post_type, 'posts_per_page' => $number, 'orderby' => $order, 'post__not_in' => $exclude, 'meta_key' => '_thumbnail_id', 'no_found_rows' => true); // Taxonomy args if (!empty($taxonomy) && !empty($terms)) { $query_args['tax_query'] = array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $terms)); } // Query posts $my_query = new WP_Query($query_args); // If there are posts loop through them if ($my_query->have_posts()) { // Loop through posts while ($my_query->have_posts()) { $my_query->the_post(); ?> <?php // Get post thumbnail $thumbnail = wpex_get_post_thumbnail(array('size' => $img_size, 'width' => $img_width, 'height' => $img_height, 'alt' => wpex_get_esc_title())); ?> <?php // Get hover classes if ($img_hover) { $hover_classes = ' ' . wpex_image_hover_classes($img_hover); } else { $hover_classes = ''; } ?> <li class="wpex-widget-recent-posts-li clr"> <?php if ($thumbnail) { ?> <a href="<?php wpex_permalink(); ?> " title="<?php wpex_esc_title(); ?> " class="wpex-widget-recent-posts-thumbnail<?php echo $hover_classes; ?> "><?php echo $thumbnail; ?> </a> <?php } ?> <a href="<?php wpex_permalink(); ?> " title="<?php wpex_esc_title(); ?> " class="wpex-widget-recent-posts-title"><?php the_title(); ?> </a> <?php // Display date if enabled if ('1' != $date) { ?> <div class="wpex-widget-recent-posts-date"> <?php echo get_the_date(); ?> </div><!-- .wpex-widget-recent-posts-date --> <?php } ?> </li><!-- .wpex-widget-recent-posts-li --> <?php } ?> <?php } ?> </ul><!-- .wpex-widget-recent-posts --> <?php wp_reset_postdata(); ?> <?php // After widget WordPress hook echo $args['after_widget']; }
$post->alt = esc_attr($post->data['alt']); $post->caption = $post->data['caption']; // Pluck array to see if item has custom link $post->url = $images_links_array[$post->id]; // Validate URl $post->url = '#' !== $post->url ? esc_url($post->url) : ''; // Get correct title if ('title' == $title_type) { $attachment_title = get_the_title(); } elseif ('alt' == $title_type) { $attachment_title = esc_attr($post->data['alt']); } else { $attachment_title = get_the_title(); } // Image output $image_output = wpex_get_post_thumbnail(array('attachment' => $post->id, 'crop' => $img_crop, 'size' => $img_size, 'width' => $img_width, 'height' => $img_height, 'alt' => $post->alt)); ?> <div class="wpex-carousel-slide"> <div class="<?php echo $img_classes; ?> "> <?php // Add custom links to attributes for use with the overlay styles if ('custom_link' == $thumbnail_link && $post->url) { $atts['overlay_link'] = $post->url; } // Lightbox
foreach ($attachment_ids as $attachment_id) { ?> <?php // Add to counter $count++; ?> <?php // Only display the first 5 images if ($count < 5) { ?> <?php // Get thumbnail $thumbnail = wpex_get_post_thumbnail(array('attachment' => $attachment_id, 'size' => 'shop_catalog')); ?> <?php // Display thumbnail if there is one if ($thumbnail) { ?> <div class="wpex-slider-slide sp-slide"> <?php echo $thumbnail; ?> </div><!-- .wpex-slider-slide --> <?php }
/** * Outputs the img HTMl thubmails used in the Total VC modules * * @since 2.0.0 */ function wpex_post_thumbnail($args = array()) { echo wpex_get_post_thumbnail($args); }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ function widget($args, $instance) { // Set vars for widget usage $title = isset($instance['title']) ? $instance['title'] : ''; $title = apply_filters('widget_title', $title); $post_type = isset($instance['post_type']) ? $instance['post_type'] : ''; $taxonomy = isset($instance['taxonomy']) ? $instance['taxonomy'] : ''; $terms = isset($instance['terms']) ? $instance['terms'] : ''; $number = isset($instance['number']) ? $instance['number'] : ''; $order = isset($instance['order']) ? $instance['order'] : ''; $columns = isset($instance['columns']) ? $instance['columns'] : '3'; $img_hover = isset($instance['img_hover']) ? $instance['img_hover'] : ''; $img_size = isset($instance['img_size']) ? $instance['img_size'] : 'wpex_custom'; $img_height = !empty($instance['img_height']) ? intval($instance['img_height']) : ''; $img_width = !empty($instance['img_width']) ? intval($instance['img_width']) : ''; $img_size = $img_width || $img_height ? 'wpex_custom' : $img_size; $exclude = is_singular() ? array(get_the_ID()) : NULL; // Sanitize terms if ($terms) { $terms = str_replace(', ', ',', $terms); $terms = explode(',', $terms); } // Before widget WP hook echo $args['before_widget']; // Display title if defined if ($title) { echo $args['before_title'] . $title . $args['after_title']; } ?> <ul class="wpex-recent-posts-thumb-grid wpex-row clr"> <?php // Query args $query_args = array('post_type' => $post_type, 'posts_per_page' => $number, 'orderby' => $order, 'meta_key' => '_thumbnail_id', 'post__not_in' => $exclude, 'no_found_rows' => true); // Taxonomy args if (!empty($taxonomy) && !empty($terms)) { $query_args['tax_query'] = array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $terms)); } // Query posts $my_query = new WP_Query($query_args); ?> <?php // Set post counter variable $count = 0; ?> <?php // Loop through posts while ($my_query->have_posts()) { $my_query->the_post(); ?> <?php // Add to counter variable $count++; ?> <?php // Get post thumbnail $thumbnail = wpex_get_post_thumbnail(array('size' => $img_size, 'width' => $img_width, 'height' => $img_height, 'alt' => wpex_get_esc_title())); ?> <?php // Get hover classes if ($img_hover) { $hover_classes = ' class="' . wpex_image_hover_classes($img_hover) . '"'; } else { $hover_classes = ''; } ?> <li class="<?php echo wpex_grid_class($columns); ?> nr-col col-<?php echo $count; ?> "> <a href="<?php wpex_permalink(); ?> " title="<?php wpex_esc_title(); ?> "<?php echo $hover_classes; ?> ><?php echo $thumbnail; ?> </a> </li> <?php // Reset counter to clear floats if ($count == $columns) { $count = '0'; } ?> <?php // End loop } ?> <?php // Reset global query post data wp_reset_postdata(); ?> </ul> <?php // After widget WP hook echo $args['after_widget']; ?> <?php }
$post_permalink = wpex_get_permalink($post_id); $post_format = get_post_format($post_id); $post_thumbnail = wp_get_attachment_url(get_post_thumbnail_id()); ?> <div class="vcex-post-type-list-entry vcex-clr vcex-count-<?php echo $count; ?> "> <?php // Featured post if ('true' == $featured_post && '1' == $count) { // Featured post => image if ($post_thumbnail) { $post_thumbnail = wpex_get_post_thumbnail(array('size' => $featured_post_img_size, 'crop' => $featured_post_img_crop, 'width' => $featured_post_img_width, 'height' => $featured_post_img_height, 'alt' => $post_title_esc)); } ?> <div class="vcex-post-type-list-thumbnail vcex-clr"> <?php echo $post_thumbnail; ?> </div><!-- .vcex-post-type-list-thumbnail --> <div class="vcex-post-type-list-title vcex-clr"> <h2 class="entry-title"><?php echo $post_title; ?> </h2> </div><!-- .vcex-post-type-list-title -->