Skip to content

Only first declared size for each aspect ratio is supported #11

@kadamwhite

Description

@kadamwhite

The doc block for get_image_sizes_by_ratio() specifies that the method "Gets the first size defined for each dimension." This makes some sense if all sizes are cropped alike for a given aspect ratio, but it does mean that passing any declared image size other than the first in the image_ratio_map list causes an error because of these lines:

if ( empty( $_REQUEST['size'] ) || ! in_array( $_REQUEST['size'], $this->get_image_sizes_by_ratio() ) )
	wp_die( sprintf( __( 'Invalid %s parameter.', 'wpcom-thumbnail-editor' ), '<code>size</code>' ) );

If this is expected behavior, the documentation should be improved to explain that regardless of the size in an aspect ratio that we want to edit, we have to pass the first declared image size in $this->image_ratio_map[$ratio].

If you should be able to pass another image size name that is present in $this->image_ratio_map[$ratio] other than $this->image_ratio_map[$ratio][0], then the get_image_sizes_by_ratio method should be amended to return a more comprehensive list, or else the $_REQUEST['size'] check should be changed to validate against the full list of supported names for a given ratio.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions