From 69c0fbdf4840007b747f749c39c85d983900eb7b Mon Sep 17 00:00:00 2001 From: Wasim Akhtar <53761154+WasimM3@users.noreply.github.com> Date: Wed, 17 Jun 2020 12:49:53 +0530 Subject: [PATCH] #3668 - Improved code and merged in 1.0.52 --- components/featured-image/featured-image.php | 2 +- includes/features/functions.php | 23 +++++++++++++++----- templates/design-manager/featured-image.php | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/components/featured-image/featured-image.php b/components/featured-image/featured-image.php index 8fa93d85f..2c378a30c 100644 --- a/components/featured-image/featured-image.php +++ b/components/featured-image/featured-image.php @@ -1,7 +1,7 @@ \ No newline at end of file diff --git a/includes/features/functions.php b/includes/features/functions.php index 251afc1a8..e4c4e8423 100644 --- a/includes/features/functions.php +++ b/includes/features/functions.php @@ -1409,11 +1409,19 @@ function ampforwp_get_taxonomy_meta($term_id,$type=''){ } if(!function_exists('ampforwp_featured_markup')){ - function ampforwp_featured_markup(){ + function ampforwp_featured_markup($echo=false){ if(ampforwp_featured_video_markup('check')){ - echo ampforwp_featured_video_markup(); + if($echo == true){ + echo ampforwp_featured_video_markup(); + }else{ + return ampforwp_featured_video_markup(); + } }else{ - echo ampforwp_get_featured_image_markup(); + if($echo == true){ + echo ampforwp_get_featured_image_markup(); + }else{ + return ampforwp_get_featured_image_markup(); + } } } } @@ -1517,7 +1525,9 @@ function ampforwp_featured_video_markup($check=''){ if(function_exists('rh_admin_notice_warning') && !empty($video_post)){ $video_url = $video_post[0]['video_post_embed_url']; $video_url = explode("=",$video_url); - $amp_f_video = ''; + if(isset($video_url[1])){ + $amp_f_video = ''; + } } $class = "amp-wp-article-featured-image wp-caption"; if(ampforwp_get_setting('amp-design-selector')==4){ @@ -1554,12 +1564,15 @@ function ampforwp_get_featured_image_markup($post_id=0, $data=''){ } $amp_html='';$height ='';$width='';$src='';$srcet='';$alt='';$caption=''; if( true == ampforwp_has_post_thumbnail() ) { + if (has_post_thumbnail( $post_id ) ){ + $thumb_id = get_post_thumbnail_id($post_id); $post_content = get_post_field('post_content', $post_id); 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; } + if(ampforwp_get_setting('amp-design-selector')==4){ $image_size = ampforwp_get_setting('swift-featued-image-size'); $image_size = apply_filters( 'ampforwp_featured_image_size', $image_size ); @@ -1633,7 +1646,7 @@ function ampforwp_get_featured_image_markup($post_id=0, $data=''){ $class = "amp-featured-image"; } $fimgdata = ''; - if($src!=""){ + if($amp_html!=""){ $fimgdata = '
'.$amp_html; // xss escaping done before. if ( $caption ) { $fimgdata .='

'.wp_kses_data($caption).' diff --git a/templates/design-manager/featured-image.php b/templates/design-manager/featured-image.php index 638d12759..626144402 100644 --- a/templates/design-manager/featured-image.php +++ b/templates/design-manager/featured-image.php @@ -7,7 +7,7 @@