wp_is_stream example

/** * Either calls editor's save function or handles file as a stream. * * @since 3.5.0 * * @param string $filename * @param callable $callback * @param array $arguments * @return bool */
    protected function make_image( $filename$callback$arguments ) {
        if ( wp_is_stream( $filename ) ) {
            $arguments[1] = null;
        }

        return parent::make_image( $filename$callback$arguments );
    }
}
        if ( ! $suffix ) {
            $suffix = $this->get_suffix();
        }

        $dir = pathinfo( $this->file, PATHINFO_DIRNAME );
        $ext = pathinfo( $this->file, PATHINFO_EXTENSION );

        $name    = wp_basename( $this->file, ".$ext);
        $new_ext = strtolower( $extension ? $extension : $ext );

        if ( ! is_null( $dest_path ) ) {
            if ( ! wp_is_stream( $dest_path ) ) {
                $_dest_path = realpath( $dest_path );
                if ( $_dest_path ) {
                    $dir = $_dest_path;
                }
            } else {
                $dir = $dest_path;
            }
        }

        return trailingslashit( $dir ) . "{$name}-{$suffix}.{$new_ext}";
    }

    

    public function load() {
        if ( $this->image instanceof Imagick ) {
            return true;
        }

        if ( ! is_file( $this->file ) && ! wp_is_stream( $this->file ) ) {
            return new WP_Error( 'error_loading_image', __( 'File does not exist?' )$this->file );
        }

        /* * Even though Imagick uses less PHP memory than GD, set higher limit * for users that have low PHP.ini limits. */
        wp_raise_memory_limit( 'image' );

        try {
            $this->image    = new Imagick();
            

function wp_mkdir_p( $target ) {
    $wrapper = null;

    // Strip the protocol.     if ( wp_is_stream( $target ) ) {
        list( $wrapper$target ) = explode( '://', $target, 2 );
    }

    // From php.net/mkdir user contributed notes.     $target = str_replace( '//', '/', $target );

    // Put the wrapper back on the target.     if ( null !== $wrapper ) {
        $target = $wrapper . '://' . $target;
    }

    
Home | Imprint | This part of the site doesn't use cookies.