astra_get_post_thumbnail( string $before = '', string $after = '', bool $echo = true )
Astra get post thumbnail image
Description
Parameters
- $before
-
(string) (Optional) Markup before thumbnail image.
Default value: ''
- $after
-
(string) (Optional) Markup after thumbnail image.
Default value: ''
- $echo
-
(bool) (Optional) Output print or return.
Default value: true
Return
(string|void)
Source
File: inc/markup-extras.php
function astra_get_post_thumbnail( $before = '', $after = '', $echo = true ) {
$output = '';
$check_is_singular = is_singular();
$featured_image = true;
if ( $check_is_singular ) {
$is_featured_image = astra_get_option_meta( 'ast-featured-img' );
} else {
$is_featured_image = astra_get_option( 'ast-featured-img' );
}
if ( 'disabled' === $is_featured_image ) {
$featured_image = false;
}
$featured_image = apply_filters( 'astra_featured_image_enabled', $featured_image );
$blog_post_thumb = astra_get_option( 'blog-post-structure' );
$single_post_thumb = astra_get_option( 'blog-single-post-structure' );
if ( ( ( ! $check_is_singular && in_array( 'image', $blog_post_thumb ) ) || ( is_single() && in_array( 'single-image', $single_post_thumb ) ) || is_page() ) && has_post_thumbnail() ) {
if ( $featured_image && ( ! ( $check_is_singular ) || ( ! post_password_required() && ! is_attachment() && has_post_thumbnail() ) ) ) {
$post_thumb = apply_filters(
'astra_featured_image_markup',
get_the_post_thumbnail(
get_the_ID(),
apply_filters( 'astra_post_thumbnail_default_size', 'large' ),
apply_filters( 'astra_post_thumbnail_itemprop', '' )
)
);
if ( '' != $post_thumb ) {
$output .= '<div class="post-thumb-img-content post-thumb">';
if ( ! $check_is_singular ) {
$output .= apply_filters(
'astra_blog_post_featured_image_link_before',
'<a ' . astra_attr(
'article-image-url',
array(
'class' => '',
'href' => esc_url( get_permalink() ),
)
) . ' >'
);
}
$output .= $post_thumb;
if ( ! $check_is_singular ) {
$output .= apply_filters( 'astra_blog_post_featured_image_link_after', '</a>' );
}
$output .= '</div>';
}
}
}
if ( ! $check_is_singular ) {
$output = apply_filters( 'astra_blog_post_featured_image_after', $output );
}
$output = apply_filters( 'astra_get_post_thumbnail', $output, $before, $after );
if ( $echo ) {
echo $before . $output . $after; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
return $before . $output . $after;
}
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 1.0.15 | Introduced. |