• I am just converting to Twenty Fifteen from another theme and absolutely love it! But all my featured images in the old theme had dimensions 1000px by 500px high. Twenty Fifteen assumes dimensions of 825px by 510px.

    For my existing featured images, there is no problem. Twenty Fifteen keeps their 2-to-1 aspect ratio intact. But when I upload new images of dimensions 1000px by 500px, it crops them to have the new aspect ratio.

    How can I modify Twenty Fifteen to allow me to upload new 1000px by 500px images, not have them cropped, and preserve their 2-to-1 aspect ratio?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter GlynHolton

    (@glynholton)

    OK. I got this to work by inserting the following code into a child theme’s functions.php. You should be able to insert other dimsntions than my 1000×500:

    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 1000, 500 );

    Thread Starter GlynHolton

    (@glynholton)

    I spoke too soon. The above fix appears to not be working. I just uploaded a feature image for one of my posts. It is 1000×500, but the theme cropped it to be the default dimensions of TwentyFifteen images.

    If anyone has ideas on how to resolve this, I will most appreciate them!

    Thread Starter GlynHolton

    (@glynholton)

    OK. I figured this out … but now have a quandary.

    To make the code I gave earlier work, you also must find the similar code in the Twenty Fifteen parent theme and comment it out. Here is that code that needs to be commented out

    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 825, 510, true );

    My quandary is why this should be necessary. If I put code in the child theme’s functions.php file, shouldn’t it override similar code in the parent theme’s functions.php? Isn’t the point of having a child theme so you don’t have to edit the parent theme’s files?

    Man try this

    add_theme_support( ‘post-thumbnails’ );
    set_post_thumbnail_size( 825, 0, true );

    if doesn’t help try this
    add_theme_support( ‘post-thumbnails’ );
    set_post_thumbnail_size( 825, 0, false );

    first or second should work. Sorry want to sleep very tired.

    it does not work with child theme ??
    Only works if i change from parent theme.

    This should do the trick:
    https://codex.www.ads-software.com/Function_Reference/remove_theme_support

    // in your Child Theme's functions.php    
    
    // Use the after_setup_theme hook with a priority of 11 to load after the
    // parent theme, which will fire on the default priority of 10
    add_action( 'after_setup_theme', 'remove_featured_images_from_child_theme', 11 ); 
    
    function remove_featured_images_from_child_theme() {
    
        // This will remove support for post thumbnails on ALL Post Types
        remove_theme_support( 'post-thumbnails' );
    
        // Add this line in to re-enable support at your chosen size
        add_theme_support( 'post-thumbnails' );
        set_post_thumbnail_size( 825, 0, true );
    }

    unsquare, a BIG thank you. This is exactly what i have been searching for =)

    unsquare, this was very helpful. Thank you!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to change the default aspect ratio of featured images?’ is closed to new replies.