WP_Image_Editor::crop() WordPress Method
The WP_Image_Editor::crop() functionCrops an image. Parameters $src (string) (required) Path to the image file. $src_x (int) (required) The x-coordinate of the top-left corner of the crop region. $src_y (int) (required) The y-coordinate of the top-left corner of the crop region. $src_w (int) (required) The width of the crop region. $src_h (int) (required) The height of the crop region. $dst_w (int) (optional) The width of the destination image. If omitted, the width of the source image will be used. $dst_h (int) (optional) The height of the destination image. If omitted, the height of the source image will be used. $src_abs (bool) (optional) If true, the crop region will be treated as absolute coordinates within the source image. If false (the default), the crop region will be treated as relative coordinates. Returns (bool|WP_Error) True on success, WP_Error on failure.
WP_Image_Editor::crop( int $src_x, int $src_y, int $src_w, int $src_h, int $dst_w = null, int $dst_h = null, bool $src_abs = false ) #
Crops Image.
Contents
Parameters
- $src_x
(int)(Required)The start x position to crop from.
- $src_y
(int)(Required)The start y position to crop from.
- $src_w
(int)(Required)The width to crop.
- $src_h
(int)(Required)The height to crop.
- $dst_w
(int)(Optional) The destination width.
Default value: null
- $dst_h
(int)(Optional) The destination height.
Default value: null
- $src_abs
(bool)(Optional) If the source crop points are absolute.
Default value: false
Return
(true|WP_Error)
Source
File: wp-includes/class-wp-image-editor.php
abstract public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false );
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.5.0 | Introduced. |