Astra_Related_Posts_Markup::astra_get_related_post_featured_image( int $current_post_id, string $before = '', string $after = '', boolean $echo = true )

Render Featured Image HTML.


Description


Parameters

$current_post_id

(int) (Required) current post ID.

$before

(string) (Optional) Markup before thumbnail image.

Default value: ''

$after

(string) (Optional) Markup after thumbnail image.

Default value: ''

$echo

(boolean) (Optional) Output print or return.

Default value: true


Return

(string|null)


Source

File: inc/modules/related-posts/class-astra-related-posts-markup.php

	public function astra_get_related_post_featured_image( $current_post_id, $before = '', $after = '', $echo = true ) {
		$related_post_structure = astra_get_option_meta( 'related-posts-structure' );

		if ( ! in_array( 'featured-image', $related_post_structure ) ) {
			return;
		}

		$post_thumb = apply_filters(
			'astra_related_post_featured_image_markup',
			get_the_post_thumbnail(
				$current_post_id,
				apply_filters( 'astra_related_posts_thumbnail_default_size', 'large' ),
				apply_filters( 'astra_related_posts_thumbnail_itemprop', '' )
			)
		);

		$appended_class = has_post_thumbnail( $current_post_id ) ? 'post-has-thumb' : 'ast-no-thumb';

		$featured_img_markup = '<div class="ast-related-post-featured-section ' . $appended_class . '">';

		if ( '' !== $post_thumb ) {
			$featured_img_markup .= '<div class="post-thumb-img-content post-thumb">';
			$featured_img_markup .= astra_markup_open(
				'ast-related-post-image',
				array(
					'open'  => '<a %s>',
					'echo'  => false,
					'attrs' => array(
						'class' => '',
						'href'  => esc_url( get_permalink() ),
					),
				)
			);
			$featured_img_markup .= $post_thumb;
			$featured_img_markup .= '</a> </div>';
		}

		$featured_img_markup  = apply_filters( 'astra_related_post_featured_image_after', $featured_img_markup );
		$featured_img_markup .= '</div>';

		$featured_img_markup = apply_filters( 'astra_related_post_thumbnail', $featured_img_markup, $before, $after );

		if ( false === $echo ) {
			return $before . $featured_img_markup . $after;
		}

		echo $before . $featured_img_markup . $after; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
	}

Changelog

Changelog
Version Description
3.5.0 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.