• Hi there,

    After upgrading WordPress from 3.8.8 to 4.2.2 I have found the image cropping routine is not working properly [accessed via Admin > Appearance > Header > Add new image > Choose your image > Select and Crop > …]

    I have tried this both on my custom theme and on the twentyeleven theme. In both cases if I set the header-image-height to 0 the image cropping routine has a heart attack (same happens if I set the width to zero btw).

    — To reproduce: —

    Edit functions.php in twentyeleven theme and set HEADER_IMAGE_HEIGHT to 0

    In my own custom theme setting height to zero also crashes image cropping. The code looks like this in my functions.php :

    $defaults = array(
    	'width'                  => 500,
    	'height'                 => 0
    );
    add_theme_support( 'custom-header', $defaults );

    Hope this makes sense. Let me know if I can provide more info.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    What do you mean by crashes?

    Thread Starter Mr B

    (@yohansb)

    ?? Yeh I wasn’t being clear there, my apologies. So the image cropping screen comes up with the selected image, however I cannot select / drag / crop the image (and no portion of the image is selected). If the dimensions are wrong then there is no “skip” option. Clicking the “Crop Image” button results in the error “There has been an error cropping your image.” .. and this is presumably because no crop area is specified (and obviously I cannot specify one)

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Does the issue persist with all plugins deactivated?

    Thread Starter Mr B

    (@yohansb)

    Yes, deactivated all plugins.

    I tried setting image height to 1 in functions.php.. Looks like the crop selection area is off screen / in an area I cannot click. Same thing happens if height is left unspecified in functions.php:

    $defaults = array(
    	'width'                  => 500
    );
    add_theme_support( 'custom-header', $defaults );

    Meanwhile add the height back into functions.php and the image cropper starts working again:

    $defaults = array(
    	'width'                  => 500,
    	'height'                 => 100
    );
    add_theme_support( 'custom-header', $defaults );
    Thread Starter Mr B

    (@yohansb)

    I wouldn’t mind just setting the height to 100, *however* in many cases we will desire no header image at all, and in that case it puts a big ugly white square with a border when I use the ‘Hide image’ button (Appearance > Header image > Hide image)

    Thread Starter Mr B

    (@yohansb)

    — In summary: —
    * if height is zero : I cannot upload a new header image (occurs in twentyeleven theme too, even with all plugins disabled)
    * if the height isn’t zero : when I hide the header image the result is an ugly box on the screen

    — Workaround —
    OK my workaround for this issue is to upload a blank header image and set the header height to a really small number, but leave it flexible:

    $defaults = array(
    	'flex-height'            => true,
    	'flex-width'             => false,
    	'width'                  => 957,
    	'height'                 => 15  # Can't upload header images if zero *cry*
    );
    add_theme_support( 'custom-header', $defaults );

    NOW my users can choose to have a header image / or a blank header image / or upload their own.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Header image cropping crashes when height/width is zero in functions.php’ is closed to new replies.