• xzoom

    (@xzoom)


    Hello!

    I need a customized size for my featured image, and I added the following theme code:

    Functions.php

    if ( function_exists( 'add_theme_support' ) ) {
    	add_theme_support( 'post-thumbnails' );
    	add_image_size( 'homepage-thumb', 300, 150 );
    }

    home.php

    the_post_thumbnail('homepage-thumb')

    But my featured image at home.php remains as 200 x 150. (I tried to upload a new image and set it as featured post image)

    It is a different behave when you are working in a multisite network?

    Thanks a lot!

Viewing 3 replies - 1 through 3 (of 3 total)
  • No, this feature is the same in a single installation as it is in multisite.

    Are you certain that the page in question is using the home.php template file and not the front-page.php template file (or some other template)?

    Do you have a link to your site so we can see the behavior?

    Thread Starter xzoom

    (@xzoom)

    Thanks Curtiss,

    I’m creating a new child theme (parent is twenty tweelve) … and I’m sure I’m using the home.php…

    I can’t show you the site now… but… I can paste the code that “the_post_thumbnail(‘homepage-thumb’)” generated:

    <img width=”200″ height=”150″ src=”https://xxxxxx/test/files/2013/02/image4-200×150.jpg&#8221; class=”attachment-homepage-thumb wp-post-image” alt=”image4″ />

    As you can see, the img widht is not the “homepage-thumb”

    Actually, WordPress did exactly what you told it to do.

    In your code, you asked WordPress to resize all images proportionally (no cropping or stretching) to be no wider than 300 pixels and no taller than 150px. Since your image was narrow enough, in order for the image to be resized to less than 150px tall, the width had to be reduced to 200.

    If you want your images resized and cropped to exactly 300×150, you need to use:

    add_image_size( 'homepage-thumb', 300, 150, true );

    That true at the end tells WordPress to crop it to those exact dimensions, rather than resizing proportionally.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add featured images’ is closed to new replies.