astra_blog_post_get_featured_item()
To featured image / gallery / audio / video etc. As per the post format.
Description
Return
(mixed)
Source
File: inc/blog/blog.php
function astra_blog_post_get_featured_item() { $post_featured_data = ''; $post_format = get_post_format(); if ( has_post_thumbnail() ) { $post_featured_data = '<a href="' . esc_url( get_permalink() ) . '" >'; $post_featured_data .= get_the_post_thumbnail(); $post_featured_data .= '</a>'; } else { switch ( $post_format ) { case 'image': break; case 'video': $post_featured_data = astra_get_video_from_post( get_the_ID() ); break; case 'gallery': $post_featured_data = get_post_gallery( get_the_ID(), false ); if ( isset( $post_featured_data['ids'] ) ) { $img_ids = explode( ',', $post_featured_data['ids'] ); $image_alt = get_post_meta( $img_ids[0], '_wp_attachment_image_alt', true ); $image_url = wp_get_attachment_url( $img_ids[0] ); if ( isset( $img_ids[0] ) ) { $post_featured_data = '<a href="' . esc_url( get_permalink() ) . '" >'; $post_featured_data .= '<img src="' . esc_url( $image_url ) . '" alt="' . esc_attr( $image_alt ) . '" >'; $post_featured_data .= '</a>'; } } break; case 'audio': $post_featured_data = do_shortcode( astra_get_audios_from_post( get_the_ID() ) ); break; } } echo $post_featured_data; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped }
Expand full source code Collapse full source code View on Trac
Changelog
Version | Description |
---|---|
1.0 | Introduced. |