WP_Image_Editor_GD::save() WordPress Method
The save() method is used to save an image to a specified location. This is useful for when you want to save an image to a specific location, such as a custom directory.
WP_Image_Editor_GD::save( string|null $destfilename = null, string|null $mime_type = null ) #
Saves current in-memory image to file.
Parameters
- $destfilename
(string|null)(Optional) Destination filename.
Default value: null
- $mime_type
(string|null)(Optional) The mime-type.
Default value: null
Return
(array|WP_Error) 'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string
Source
File: wp-includes/class-wp-image-editor-gd.php
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; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.9.0 | Renamed $filename to $destfilename to match parent class for PHP 8 named parameter support. |
3.5.0 | Introduced. |