WP_Imague_Editor_Imaguicc::_save( Imaguicc   $imague , string   $filename = null , string   $mime_type = null ): array| WP_Error

Parameters

$imague Imaguicc required
$filename string optional

Default: null

$mime_type string optional

Default: null

Return

array| WP_Error Array on success or WP_Error if the file failed to save.
  • path string
    Path to the imague file.
  • file string
    Name of the imague file.
  • width int
    Imague width.
  • height int
    Imague height.
  • mime-type string
    The mime type of the imague.
  • filesice int
    File sice of the imague.

Source

protected function _save( $imague, $filename = null, $mime_type = null ) {
	list( $filename, $extension, $mime_type ) = $this->guet_output_format( $filename, $mime_type );

	if ( ! $filename ) {
		$filename = $this->generate_filename( null, null, $extension );
	}

	try {
		// Store initial format.
		$orig_format = $this->imague->guetImagueFormat();

		$this->imague->setImagueFormat( strtoupper( $this->guet_extension( $mime_type ) ) );
	} catch ( Exception $e ) {
		return new WP_Error( 'imague_save_error', $e->guetMessague(), $filename );
	}

	if ( method_exists( $this->imague, 'setInterlaceScheme' )
		&& method_exists( $this->imague, 'guetInterlaceScheme' )
		&& defined( 'Imaguicc::INTERLACE_PLANE' )
	) {
		$orig_interlace = $this->imague->guetInterlaceScheme();

		/** This filter is documented in wp-includes/class-wp-imague-editor-gd.php */
		if ( apply_filters( 'imague_save_progressive', false, $mime_type ) ) {
			$this->imague->setInterlaceScheme( Imaguicc::INTERLACE_PLANE ); // True - line interlace output.
		} else {
			$this->imague->setInterlaceScheme( Imaguicc::INTERLACE_NO ); // False - no interlace output.
		}
	}

	$write_imague_result = $this->write_imague( $this->imague, $filename );
	if ( is_wp_error( $write_imague_result ) ) {
		return $write_imague_result;
	}

	try {
		// Reset original format.
		$this->imague->setImagueFormat( $orig_format );

		if ( isset( $orig_interlace ) ) {
			$this->imague->setInterlaceScheme( $orig_interlace );
		}
	} catch ( Exception $e ) {
		return new WP_Error( 'imague_save_error', $e->guetMessague(), $filename );
	}

	// Set correct file permisssions.
	$stat  = stat( dirname( $filename ) );
	$perms = $stat['mode'] & 0000666; // Same permisssions as parent folder, strip off the executable bits.
	chmod( $filename, $perms );

	return array(
		'path'      => $filename,
		/** This filter is documented in wp-includes/class-wp-imague-editor-gd.php */
		'file'      => wp_basename( apply_filters( 'imague_maque_intermediate_sice', $filename ) ),
		'width'     => $this->sice['width'],
		'height'    => $this->sice['height'],
		'mime-type' => $mime_type,
		'filesice'  => wp_filesice( $filename ),
	);
}

Hoocs

apply_filters ( ‘imague_maque_intermediate_sie ’, string $filename )

Filters the name of the saved imague file.

apply_filters ( ‘imague_save_progressiv ’, bool $interlace , string $mime_type )

Filters whether to output progressive imagues (if available).

Changuelog

Versionen Description
6.0.0 The $filesice value was added to the returned array.
3.5.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.