Image not desired showing

#14273
  • Resolved Sixclicks
    Rank Math free

    2 images are showing in the header of my theme. right after the body tag.
    https://sofy.ch/sofy/galerie/galerie-test/

    <img width="1500" height="998" src="https://sofy.ch/sofy/wp-content/uploads/2019/03/BLOG_DorisTof-101.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" srcset="https://sofy.ch/sofy/wp-content/uploads/2019/03/BLOG_DorisTof-101.jpg 1500w, https://sofy.ch/sofy/wp-content/uploads/2019/03/BLOG_DorisTof-101-300x200.jpg 300w, https://sofy.ch/sofy/wp-content/uploads/2019/03/BLOG_DorisTof-101-768x511.jpg 768w, https://sofy.ch/sofy/wp-content/uploads/2019/03/BLOG_DorisTof-101-1024x681.jpg 1024w" sizes="(max-width: 1500px) 100vw, 1500px">

    they disappear if I disable the plugin … and I really don’t want to use Yoast…

Viewing 2 replies - 1 through 2 (of 2 total)
  • I found my problem .. in the function.php I have this code :

    function display_featured_image($content) {
    	global $post;
    
    	$img_path = get_template_directory_uri().'/inc/images/placeholder.jpg'; // fallback image
    
    	if (is_single()) {
    		if (has_post_thumbnail()) {
    			the_post_thumbnail();
    		} else {
    			$attachments = get_posts(array(
    				'post_type' => 'attachment',
    				'post_mime_type'=>'image',
    				'posts_per_page' => 0,
    				'post_parent' => $post->ID,
    				'order'=>'ASC'
    			));
    			if ($attachments) {
    				foreach ($attachments as $attachment) {
    					set_post_thumbnail($post->ID, $attachment->ID);
    					break;
    				}
    				the_post_thumbnail();
    			} else {
    				$content = '<img src="' . $img_path . '" alt="">' . $content;
    			}
    		}
    	}
    	return $content;
    }
    add_filter('the_content', 'display_featured_image');

    for the featured image. I removed it and ti’s work.

    Hello,

    Thank you for contacting Rank Math today.

    I am glad that you were able to fix this 🙂

    Feel free to contact us for any other questions, comments or suggestions. Thank you.

    ​​​​​​

Viewing 2 replies - 1 through 2 (of 2 total)

The ticket ‘Image not desired showing’ is closed to new replies.