• laat

    (@laat)


    I’m building a theme with custom headers. The header image should have a height of 300 pixels. The width should be whatever the width is from the image.

    The problem is, when I don’t fill in the width by custom header, wordpress resizes the uploading image when it’s bigger than 1500px width to 1500px. When I fill in the width option to for example 3000px. In step 3 WordPress is resizing my image to 300px height and 3000px width.

    I just want to crop 300 pixels high from the image and have just a custom width. How can I arrange that?

    This is my code:

    $custom_header_args = array(
    'width'         => 3000,
    'height'        => 300,
    'header-text'   => false,
    'flex-width'    => true,
    'flex-height'   => false,
    'default-image' => get_template_directory_uri() . '/images/backup-image.jpg',
    );
    add_theme_support( 'custom-header', $custom_header_args);

Viewing 1 replies (of 1 total)
  • After searching for a while for this for myself, and almost making a bug ticket, I found this: https://core.trac.www.ads-software.com/ticket/17242#comment:53

    You have to add the argument ‘max-width’ and some huge number. Here’s mine:

    $args = array(
       'default-image' => get_template_directory_uri() . '/images/headimage.jpg',
       'random-default' => true,
       'height'        => 350,
       'flex-width'   => true,
       'max-width' => 4000,
       'header-text'  => false,
       'uploads'       => true,
    );
    add_theme_support( 'custom-header', $args );

    No idea why that argument is missing from the codex.

Viewing 1 replies (of 1 total)
  • The topic ‘How can I disable scaling/resizing in custom headers?’ is closed to new replies.