/** * HTML Markup for featured image thumb. * * @since 3.6.4 */ function highend_featured_image_thumb( $args = array() ) { $args = wp_parse_args( $args, array( 'post_id' => '', 'width' => false, 'height' => false, 'crop' => false, 'alt' => '', 'lightbox' => false, ) ); $post_id = $args['post_id']; $thumb = get_post_thumbnail_id( $post_id ); $image = highend_resize( $thumb, $args['width'], $args['height'], $args['crop'] ); // Caption $caption = ''; if ( is_single( $post_id ) || is_page( $post_id ) ) { $caption = wp_get_attachment_caption( $thumb ); if ( ! empty( $caption ) ) { $caption = '' . wp_kses( $caption, wp_kses_allowed_html('html') ) . ''; } } // If custom ALT tag is provided use it, otherwise use page title. if ( empty( $args['alt'] ) ) { $thumb_alt = trim( strip_tags( get_post_meta( $thumb, '_wp_attachment_image_alt', true ) ) ); // phpcs:ignore if ( ! empty( $thumb_alt ) ) { $args['alt'] = $thumb_alt; } else { $args['alt'] = get_the_title(); } } if ( empty( $image ) || ! isset( $image['url'] ) || empty( $image['url'] ) ) { return; } if ( $args['lightbox'] ) { $atts = 'data-title="' . esc_attr( get_the_title( $post_id ) ) . '" href="' . esc_url( wp_get_attachment_url( $thumb ) ) . '" rel="prettyPhoto"'; } else { $atts = 'href="' . esc_url( get_permalink( $post_id ) ) . '"'; } $srcset = $args['crop'] ? '' : ' srcset="' . esc_attr( wp_get_attachment_image_srcset( $thumb, array( $image['width'], $image['height'] ) ) ) . '"'; ?>