Summery Summery
Crops Image.
Syntax Syntax
Parameters Parameters
- $src_x
-
(Required) The start x position to crop from.
- $src_y
-
(Required) The start y position to crop from.
- $src_w
-
(Required) The width to crop.
- $src_h
-
(Required) The height to crop.
- $dst_w
-
(Optional) The destination width.
Default value: null
- $dst_h
-
(Optional) The destination height.
Default value: null
- $src_abs
-
(Optional) If the source crop points are absolute.
Default value: false
Return Return
(bool|WP_Error)
Source Source
File: wp-includes/class-wp-image-editor-imagick.php
if ( $src_abs ) { $src_w -= $src_x; $src_h -= $src_y; } try { $this->image->cropImage( $src_w, $src_h, $src_x, $src_y ); $this->image->setImagePage( $src_w, $src_h, 0, 0 ); if ( $dst_w || $dst_h ) { // If destination width/height isn't specified, // use same as width/height from source. if ( ! $dst_w ) { $dst_w = $src_w; } if ( ! $dst_h ) { $dst_h = $src_h; } $thumb_result = $this->thumbnail_image( $dst_w, $dst_h ); if ( is_wp_error( $thumb_result ) ) { return $thumb_result; } return $this->update_size(); } } catch ( Exception $e ) { return new WP_Error( 'image_crop_error', $e->getMessage() ); } return $this->update_size(); }
Advertisement
Changelog Changelog
Version | Description |
---|---|
3.5.0 | Introduced. |