Ramón Wilhelm
Ramón Wilhelm

Reputation: 997

Wordpress: Feature Image won't change its size

In my theme's function.php:

//Custom Image Sizes
set_post_thumbnail_size( 150, 150, true );
add_image_size( 'kaira-slider', 1140, 500, true );
add_image_size( 'kaira-featured', 652, 375, true );
add_image_size( 'kaira-grid-post', 360, 230, true );

And in my content.php:

<div class="featured-img">
        <a href="<?php the_permalink(); ?>" class="post-thumbnail">
            <?php the_post_thumbnail('kaira-featured', array('class' => 'img-responsive')); ?>
        </a>
    </div>

I tried to change the size from 'kaira-slider' to 'kaira-featured', but the size won't change. I'm using the kaira-Theme.

How to force the theme to change the image size?

Upvotes: 0

Views: 59

Answers (5)

Johannes
Johannes

Reputation: 67768

As you wrote yourself, you need to change this in your CSS. So, go to the page where you want the displayed image to have a different size and use the browser developer tools to find out which CSS selector is used to address that image. Most likely this will be a selector consisting of more than one tag and class (which is why it's not so easy to overwerite it)

Then use that same CSS selector in your custom CSS / stylesheet and define a different width (and most likely "height: auto" to keep the correct proportion).

Upvotes: 1

Ram&#243;n Wilhelm
Ram&#243;n Wilhelm

Reputation: 997

Sorry, if I wasted your time. But I also thank you for trying to help me. I tried to modify the sizes via PHP. I started another way and I'm solving my problem with CSS, even it is a lot of work.

I don't understand why the Kaira Theme is so stubborn. Theme: https://wordpress.org/themes/kaira/ Unfortunately it is the only theme that are fitting to my blog. Otherwise I should have changed it already.

Edit: I used to follow these instruction - useless. Not for the comlicated Kaira Theme https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/

Upvotes: 0

Moshe Harush
Moshe Harush

Reputation: 701

After any change of image size you must to regenerate the all images thumbnails.

For regenerate use Regenerate thumbnails plugin.

Upvotes: 2

maurice bruijn
maurice bruijn

Reputation: 81

Change:

the_post_thumbnail('kaira-featured', array('class' => 'img-responsive'));

To: the_post_thumbnail('kaira-featured');

Upvotes: 0

maurice bruijn
maurice bruijn

Reputation: 81

add_image_size( 'kaira-featured', 652, 375, true );

Change the values 652 and 375 to whatever you like

Upvotes: 1

Related Questions