5

I am creating a custom Wordpress theme based on the Bones WP theme. I'm having a problem where an image size that I've specified in functions.php using add_image_size() isn't showing the correct width x height in the Insert Media dialog.

This is how I add the new image size in functions.php

add_image_size( 'portfolio-image-full', 800, 400, true );

And using the existing Bones functions, this is how I make this image size appear in the Attachment Display Settings

add_filter( 'image_size_names_choose', 'bones_custom_image_sizes' );

function bones_custom_image_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'portfolio-image-full' => __('Portfolio large image'),
        'portfolio-image-small' => __('Portfolio small image')

    ) );
}

But after uploading an image the 'Portfolio large image' size is 640x320, when it should be 800x400:

enter image description here

What am I doing wrong?

14

Problem solved - the image width was being limited by $content_width set to 640 in the functions.php file included with Bones WP theme. Hopefully this information will help anyone else struggling with similar problems.

| improve this answer | |
  • This way my problems as well, and I'm glad I found this answer! For me $content_width was set in my parent theme. I guess it is obvious to most people, but I'll state it anyway: if you are using a child theme it is very easy to just override it by setting $content_width to a new value in your child theme functions.php, like this: $content_width = 1200; – Adrian B Dec 4 '19 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.