WPDev.one
Core Function
View Source on Trac ↗

wp_save_image_file()

wp_save_image_file( mixed $filename, mixed $image, mixed $mime_type, mixed $post_id )

Saves image to file.

Parameters 4 required

Name / Type Description
$filename
string

Name of the file to be saved.

Required
$image
WP_Image_Editor

The image editor instance.

Required
$mime_type
string

The mime type of the image.

Required
$post_id
int

Attachment post ID.

Required

Return Value

((array)
(array | WP_Error | bool) { Array on success or WP_Error if the file failed to save. When called with a deprecated value for the `$image` parameter, i.e. a non-`WP_Image_Editor` image resource or `GdImage` instance, the function will return true on success, false on failure.

Function Information

Since Version
2.9.0
Source File
wp-admin/includes/image-edit.php
Advertisement