• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.1 Please provide an image whose longer side is no more than twice the length of its shorter side.

time

Active member
#1
When a member of my make up avatar images, some images display the message "Please provide an image whose longer side is no more than twice the length of its shorter side.". So, how do I fix this problem
 

tenants

Well-known member
#2
No way that I know of in the ACP, it's a core restriction. Ask your member to use an image that is approximately square (or at least closer to square than rectangle)

This is a restriction when uploading images to prevent the different scaled images looking strange
Code:
        // require 2:1 aspect ratio or squarer
        if ($width > 2 * $height || $height > 2 * $width)
        {
            throw new XenForo_Exception(new XenForo_Phrase('please_provide_an_image_whose_longer_side_is_no_more_than_twice_length'), true);
        }

If you look at XenForo_Model_Avatar, when creating the images for large, medium, small, the following dimensions are used:

Code:
    protected static $_sizes = array(
        'l' => 192,
        'm' => 96,
        's' => 48
    );
The image is then scaled down to the following
48x48 (small),
96x96 (medium),
192 * scaled width (large)

Although... there is some cropping allowed, if you imagine scaling down a very wide image:

stretch.png

into a 96x96 square, it might look strange (although, I'm not completely sure why we can't use the cropping for all size images and allow very wide images to be cropped)

Maybe ask for this as an enhancement?
 
Last edited:

time

Active member
#3
No way that I know of in the ACP, it's a core restriction. Ask your member to use an image that is approximately square (or at least closer to square than rectangle)

This is a restriction when uploading images to prevent the different scaled images looking strange
Code:
        // require 2:1 aspect ratio or squarer
        if ($width > 2 * $height || $height > 2 * $width)
        {
            throw new XenForo_Exception(new XenForo_Phrase('please_provide_an_image_whose_longer_side_is_no_more_than_twice_length'), true);
        }

If you look at XenForo_Model_Avatar, when creating the images for large, medium, small, the following dimensions are used:

Code:
    protected static $_sizes = array(
        'l' => 192,
        'm' => 96,
        's' => 48
    );
The image is then scaled down to the following
48x48 (small),
96x96 (medium),
192 * scaled width (large)

Although... there is some cropping allowed, if you imagine scaling down a very wide image:

View attachment 51191

into a 96x96 square, it might look strange (although, I'm not completely sure why we can't use the cropping for all size images and allow very wide images to be cropped)

Maybe ask for this as an enhancement?
@tenants,
That is exactly the answer for me. thank you