0

I created a custom template. It contains 3 columns, and the middle column should only display the post thumbnail. But no matter what size attribute I'm setting, it's not changing the size the way I want. I'd like the image to take over most of the space from that column.

    <div class="col-lg-4">
       .. first column with some content
    </div><!-- col-lg-4 -->

     <div class="col-lg-4"> 
       <?php
        //post_thumbnail
        if (!empty(get_the_post_thumbnail())) : ?>
           <?php the_post_thumbnail(array(360,466), array( 'class' => 'aligncenter'));
        endif; ?>

     </div><!-- col-lg-4 -->
     <div class="col-lg-4">
         third column with some content..
    </div><!-- col-lg-4 -->

No matter what I put as a size (i also tried 'medium', 'full' etc.) it's remaining the same size as in the picture below: enter image description here

any ideas where my problem is?

EDIT

the same thing happens when I simply add

if (!empty(get_the_post_thumbnail())) : ?>
                <?php the_post_thumbnail();
            endif; ?>

or add any size (thumbnail, middle, large). It doesn't change anything..

2
  • have a look at CSS if there are rules that constrain img size Jul 26, 2018 at 10:29
  • what do you mean? which css?
    – sonja
    Jul 26, 2018 at 10:31

2 Answers 2

0

You can edit css?

img{
   display: block;
   width: 100%;
   height: auto;
   max-width: 100%;
}
10
  • but that would edit all the images not only that one specific page
    – sonja
    Jul 26, 2018 at 11:06
  • You must name the class differently for the images on this page. Jul 26, 2018 at 11:09
  • @Quang please update the answer with proper code and a bit explanation, like why would it solve the problem? Otherwise this looks like a low quality answer.
    – Fayaz
    Jul 26, 2018 at 11:22
  • @Fayaz okay you win 😌 Jul 26, 2018 at 11:29
  • 1
    @Quang I eventually got it to work! Thank you so much!
    – sonja
    Aug 2, 2018 at 10:45
0

After you added add_image_size( 'book-image', 360, 466, true ); try calling the_post_thumbnail like that: also reganrate the thumbnails

the_post_thumbnail( 'book-image' ); 
2
  • the 360,466 where just numbers to play with the size. I'd actually want the size to be responsive to the screen. so it's more a 100% according to the column size
    – sonja
    Jul 26, 2018 at 10:32
  • any other ideas how it might work?
    – sonja
    Aug 2, 2018 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.