ID;
$featured_image = "";
$amp_html = "";
$caption = "";
$f_vid = "";
if( ampforwp_is_front_page() ){
$post_id = ampforwp_get_frontpage_id();
}
if( true == ampforwp_has_post_thumbnail() ) {
// Featured Video SmartMag theme Compatibility #2559
if(class_exists('Bunyad') && Bunyad::posts()->meta('featured_video') ){
global $wp_embed;
$f_vid = 'f_vid';
$videoContent = Bunyad::posts()->meta('featured_video');
$featured_video = $wp_embed->autoembed($videoContent);
$amp_html = ampforwp_content_sanitizer($featured_video);
}elseif (has_post_thumbnail( $post_id ) ){
$thumb_id = get_post_thumbnail_id($post_id);
$post_content = $post->post_content;
if ( true !== apply_filters('ampforwp_allow_featured_image', false) && ( false !== strpos( $post_content, 'wp-image-' . $thumb_id ) || false !== strpos( $post_content, 'attachment_' . $thumb_id ) ) ) {
return;
}
$image_size = apply_filters( 'ampforwp_featured_image_size', 'full' );
$image = wp_get_attachment_image_src( $thumb_id, $image_size );
$caption = get_the_post_thumbnail_caption( $post_id );
$thumb_alt = get_post_meta( $thumb_id, '_wp_attachment_image_alt', true);
if($thumb_alt){
$alt = $thumb_alt;
}
else{
$alt = get_the_title( $post_id );
}
$alt = esc_attr($alt);
if( $image ){
$amp_html = "";
}
}
elseif ( ampforwp_is_custom_field_featured_image() ) {
$amp_img_src = ampforwp_cf_featured_image_src();
$amp_img_width = ampforwp_cf_featured_image_src('width');
$amp_img_height = ampforwp_cf_featured_image_src('height');
if( $amp_img_src ){
$amp_html = "";
}
}
elseif ( true == ampforwp_get_setting('ampforwp-featured-image-from-content') && ampforwp_get_featured_image_from_content() ){
$amp_html = ampforwp_get_featured_image_from_content();
$amp_html = preg_replace('#sizes="(.*)"#', "layout='responsive'", $amp_html);
}
if( $amp_html ){ ?>