Changeset 48798 for trunk/src/wp-includes/class-wp-image-editor-gd.php
- Timestamp:
- 08/16/2020 01:31:57 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-image-editor-gd.php
r48586 r48798 18 18 * GD Resource. 19 19 * 20 * @var resource 20 * @var resource|GdImage 21 21 */ 22 22 protected $image; … … 96 96 $this->image = @imagecreatefromstring( file_get_contents( $this->file ) ); 97 97 98 if ( ! is_ resource( $this->image ) ) {98 if ( ! is_gd_image( $this->image ) ) { 99 99 return new WP_Error( 'invalid_image', __( 'File is not an image.' ), $this->file ); 100 100 } … … 139 139 /** 140 140 * Resizes current image. 141 * Wraps _resize, since _resize returns a GD Resource.142 * 143 * At minimum, either a height or width must be provided.144 * If one of the two is set to null, the resize will145 * maintain aspect ratio according to the provided dimension.141 * 142 * Wraps `::_resize()` which returns a GD resource or GdImage instance. 143 * 144 * At minimum, either a height or width must be provided. If one of the two is set 145 * to null, the resize will maintain aspect ratio according to the provided dimension. 146 146 * 147 147 * @since 3.5.0 … … 159 159 $resized = $this->_resize( $max_w, $max_h, $crop ); 160 160 161 if ( is_ resource( $resized ) ) {161 if ( is_gd_image( $resized ) ) { 162 162 imagedestroy( $this->image ); 163 163 $this->image = $resized; … … 175 175 * @param int $max_h 176 176 * @param bool|array $crop 177 * @return resource| WP_Error177 * @return resource|GdImage|WP_Error 178 178 */ 179 179 protected function _resize( $max_w, $max_h, $crop = false ) { … … 189 189 imagecopyresampled( $resized, $this->image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); 190 190 191 if ( is_ resource( $resized ) ) {191 if ( is_gd_image( $resized ) ) { 192 192 $this->update_size( $dst_w, $dst_h ); 193 193 return $resized; … … 330 330 imagecopyresampled( $dst, $this->image, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); 331 331 332 if ( is_ resource( $dst ) ) {332 if ( is_gd_image( $dst ) ) { 333 333 imagedestroy( $this->image ); 334 334 $this->image = $dst; … … 354 354 $rotated = imagerotate( $this->image, $angle, $transparency ); 355 355 356 if ( is_ resource( $rotated ) ) {356 if ( is_gd_image( $rotated ) ) { 357 357 imagealphablending( $rotated, true ); 358 358 imagesavealpha( $rotated, true ); … … 363 363 } 364 364 } 365 365 366 return new WP_Error( 'image_rotate_error', __( 'Image rotate failed.' ), $this->file ); 366 367 } … … 380 381 $dst = wp_imagecreatetruecolor( $w, $h ); 381 382 382 if ( is_ resource( $dst ) ) {383 if ( is_gd_image( $dst ) ) { 383 384 $sx = $vert ? ( $w - 1 ) : 0; 384 385 $sy = $horz ? ( $h - 1 ) : 0; … … 392 393 } 393 394 } 395 394 396 return new WP_Error( 'image_flip_error', __( 'Image flip failed.' ), $this->file ); 395 397 } … … 416 418 417 419 /** 418 * @param resource 419 * @param string|null $filename420 * @param string|null $mime_type420 * @param resource|GdImage $image 421 * @param string|null $filename 422 * @param string|null $mime_type 421 423 * @return array|WP_Error 422 424 */
Note: See TracChangeset
for help on using the changeset viewer.