• Resolved Jess

    (@jcull76)


    Is there any way to get the featured image size to be the same regardless of the original image size? Or make it select the “medium” size created by the Media Library by default? I’m already working up a child theme but can’t find where to make this change easily. The site will have multiple authors, not all of whom know anything about manipulating images, so I need this to be as dummy-proof as possible. Thank you!!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Theme Author Brian Harris

    (@zgani)

    Hello Jess,

    The featured images are set to two specific sizes which WordPress automatically applies as an output depending on the layout selected.

    For no right sidebar the images are cropped to 1380px by 770px upon upload/resize and when the sidebar is active then the images are cropped at 672px by 372px upon upload/resize.

    If you want to change those values to your custom ones then you’d set and add the sizes via the after_setup_theme action on a callback – see @lines 77 – 80 of functions.php in the main theme.

    Hope that is what you are looking for if not then please feel free to ask some more with more details.

    Regards,
    Zulf

    Thread Starter Jess

    (@jcull76)

    So I copied those lines to the functions.php of my child theme and changed the values – and no change in the size of the featured images. I’m assuming there is additional code I need to add since this function isn’t conditional in the original theme’s file. I’m not familiar with filter or action hooks at all, so please give me baby steps. Thank you!!

    Thread Starter Jess

    (@jcull76)

    Same question asked by another user:

    http://wordpress.org/support/topic/featured-image-144

    Just changing the sizes in that code in a Child Theme’s function.php file does not change how the images are displayed. Changing the values in the original theme files would, but that defeats the purpose of using a Child Theme at all! So, Zulf, can you please point us to instructions on how to make changes to that functionality in a Child Theme?

    Thread Starter Jess

    (@jcull76)

    Here’s what finally worked, after lots of digging around!

    This page was very helpful: https://codex.wordpress.org/Plugin_API/Action_Reference/after_setup_theme

    /* Set Default Featured Image Sizes */
    
    add_action( 'after_setup_theme', 'ridizain_setup' );
    
    function ridizain_setup() {
    
    	// Enable support for Post Thumbnails, and declare two sizes.
    	add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_size( 400, 300, true );
    	add_image_size( 'ridizain-full-width', 600, 400, true );
    	add_image_size( 'ridizain-recentpost-thumb', 250, 250, true );
    }

    You have to keep “ridizain_setup” named exactly that for it to override what’s in the original theme functions.php file. The values you choose in the size lines can be whatever you want.

    Theme Author Brian Harris

    (@zgani)

    So I copied those lines to the functions.php of my child theme and changed the values – and no change in the size of the featured images.

    You then need to apply the new child function to the template location(s) where the post thumbnails are being called – in Ridizain’s case for posts, that would be the template-tags.php in the function function ridizain_post_thumbnail() starting at line 177.

    Again all of these edits are to be done in the child theme. Also the file referencing i.e. include will need to be included from the child theme’s functions.php in order for them to take effect.

    So, Zulf, can you please point us to instructions on how to make changes to that functionality in a Child Theme?

    The best place for that I can point you to is this codex section: https://codex.wordpress.org/Child_Themes

    I hope that helps point you in the right direction.

    Regards,
    Zulf

    Thread Starter Jess

    (@jcull76)

    Sorry, Zulf, your post is too late and actually completely unhelpful. See the simple solution I found in my post above. I do appreciate your attempts, but your explanations make things much more complicated than they need to be.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Set standard Featured Image size’ is closed to new replies.