• Resolved Fi Fi P

    (@fi-fi-p)


    I have continually found this a problem and no clean, simple answers.
    For my site, I want all of my standard pages to display the featured image full width at the top of the page.

    I have added the below code to my functions.php file:

    if ( function_exists( ‘add_theme_support’ ) ) {
    add_theme_support( ‘band-top’ );
    set_post_thumbnail_size( 1000, 300, array( ‘center’, ‘top’ ) );
    }

    I then regenerated my thumbnails and on my page.php I have inserted the below where the image is to appear:

    <?php
    if ( has_post_thumbnail() ) {
    the_post_thumbnail(‘band-top’);
    }

    In my CSS, to keep it responsive:

    #content-area img {
    width: 100%;
    }

    My problem is the height of my image. I want it to be 300px high without distorting the image so all featured images will appear the same size and be cropped from the top.

    Any help would be great!

Viewing 1 replies (of 1 total)
  • Thread Starter Fi Fi P

    (@fi-fi-p)

    I solved it in the end!

    If anyone else has this same problem my solution is below:

    Set Featured Image to a specific size

    In functions.php

    <?php

    add_image_size( ‘artist’, 1000, 300, array( ‘left’, ‘top’ ) ); // Hard crop left top

    Then in my page.php when I call for the feature image:

    <?php
    if ( has_post_thumbnail() ) {
    the_post_thumbnail(‘artist’);
    }
    ?>

    Don’t forget to regenerate your thumbnails!

Viewing 1 replies (of 1 total)

The topic ‘Featured image’ is closed to new replies.