Word Press: Why are my images in single.php are messed up?

When uploading images to my wp articles they are not displayed properly. (Please take a look at attached photograph: The images have not the same dimensions even though I set them within admin panel to “full width”)

This is the - I think - relevant code in functions.php:

function myBlog_features() {
  add_theme_support('title-tag');
  add_theme_support('post-thumbnails');
  add_image_size('landscape', 400, 260, true);
  add_image_size('portrait', 480, 650, true);

  set_post_thumbnail_size(700, 700);
}
add_action('after_setup_theme', 'myBlog_features');

Do I have to use a different property than add_image_size? PLease not: It is not about the featured image, the Title Picture of a blog article. My issues are related to images within the blog posts.

This is the code in single.php

 <section class="main-wrapper">
<?php 
      while(have_posts()) {
    the_post(); ?>
<article class="article main-article_single">
    <?php
if ( has_post_thumbnail() ) { 
the_post_thumbnail( 'full' );
}
?>  
    <h1 class="article-headline">
            <?php the_title() ?>
    </h1>
    <p class="article-body">
        <?php the_content(); ?>
    </p>
</article>
    </section>

Do I have to add here sth. like <?php if image …?> ?
But what would it be?

As always: Best and thank you!

Sven

I’m not sure this answers your problem, but 700x700 is rather large for a thumbnail.

No, it does not work. :slight_smile:

well, you’ve told your thumbnail to use the size ‘full’, but not specified what that is. So your thumbnail will have whatever size has been defined for ‘full’.

You havent shown us anything inside your title or content that contains image information; so we can’t see what sizing is being applied to your images.

Both wp_get_attachment_image andwp_get_attachment_image_src take a parameter for a size definition.

Yes, because I did not set these parameters. Can’t wait to leave office to try these out “wp_get_attachment_image” and “wp_get_attachment_image_src” :slight_smile:

Best and nice weekend

I don’t have any idea, what I do wrong. I can’t display more than one image besides the featured image. The images I want to upload within my blog articles don’t show up – but they are displayed in the admin board. It woud be great if anyone could take a look in my github repo. I think the relevant files are functions.php and single.php https://github.com/Sven72/blogProject2020
Many thanks!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.