This function will return the featured image without the class attribute:
function wpse239577_post_thumbnail( $image_size="full" ) {
$image_id = get_post_thumbnail_id();
$image = wp_get_attachment_image_src( $image_id, $image_size );
if ( ! $image ) {
return false;
}
return '<img src="' . esc_url( $image[0] ) . '" alt="" />';
}
Usage: echo wpse239577_post_thumbnail()
; The $size
parameter is a WordPress image size and is optional.
Also, the_post_thumbmail()
already echos its output so echo
is unnecessary. get_the_post_thumbmail()
is similar, but it returns the output.