WP_Image_Editor_GD::save
Saves current in-memory image to file.
Method of the class: WP_Image_Editor_GD{}
No Hooks.
Returns
Array|WP_Error. Array on success or WP_Error if the file failed to save.
Usage
$WP_Image_Editor_GD = new WP_Image_Editor_GD(); $WP_Image_Editor_GD->save( $destfilename, $mime_type );
- $destfilename(string|null)
- Destination filename.
Default: null - $mime_type(string|null)
- The mime-type.
Default: null
Changelog
| Since 3.5.0 | Introduced. |
| Since 5.9.0 | Renamed $filename to $destfilename to match parent class for PHP 8 named parameter support. |
| Since 6.0.0 | The $filesize value was added to the returned array. |
WP_Image_Editor_GD::save() WP Image Editor GD::save code WP 6.8.3
public function save( $destfilename = null, $mime_type = null ) {
$saved = $this->_save( $this->image, $destfilename, $mime_type );
if ( ! is_wp_error( $saved ) ) {
$this->file = $saved['path'];
$this->mime_type = $saved['mime-type'];
}
return $saved;
}