WP_Image_Editor::make_image() WordPress Method

The WP_Image_Editor::make_image() method is used to create an image from an image editor. It is used to create an image from a file, an ImageMagick image, or a GD image.

WP_Image_Editor::make_image( string $filename, callable $callback, array $arguments ) #

Either calls editor’s save function or handles file as a stream.


Parameters

$filename

(string)(Required)

$callback

(callable)(Required)

$arguments

(array)(Required)


Top ↑

Return

(bool)


Top ↑

Source

File: wp-includes/class-wp-image-editor.php

556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
protected function make_image( $filename, $callback, $arguments ) {
    $stream = wp_is_stream( $filename );
    if ( $stream ) {
        ob_start();
    } else {
        // The directory containing the original file may no longer exist when using a replication plugin.
        wp_mkdir_p( dirname( $filename ) );
    }
 
    $result = call_user_func_array( $callback, $arguments );
 
    if ( $result && $stream ) {
        $contents = ob_get_contents();
 
        $fp = fopen( $filename, 'w' );
 
        if ( ! $fp ) {
            ob_end_clean();
            return false;
        }
 
        fwrite( $fp, $contents );
        fclose( $fp );
    }
 
    if ( $stream ) {
        ob_end_clean();
    }
 
    return $result;
}


Top ↑

Changelog

Changelog
VersionDescription
3.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.