WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

WP_Image_Editor::get_output_format() protected WP 3.5.0

Returns preferred mime-type and extension based on provided file's extension and mime, or current file's extension and mime.

Will default to $this->default_mime_type if requested is not supported.

Provides corrected filename only if filename is provided.

{} Это метод класса: WP_Image_Editor{}

Хуки из метода
Возвращает

Массив. { filename|null, extension, mime-type }

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_output_format( $filename, $mime_type );
$filename(строка)

По умолчанию: null
$mime_type(строка)

По умолчанию: null

Список изменений

С версии 3.5.0 Введена.

Код WP_Image_Editor::get_output_format() WP 5.5.3

<?php
protected function get_output_format( $filename = null, $mime_type = null ) {
	$new_ext = null;

	// By default, assume specified type takes priority.
	if ( $mime_type ) {
		$new_ext = $this->get_extension( $mime_type );
	}

	if ( $filename ) {
		$file_ext  = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) );
		$file_mime = $this->get_mime_type( $file_ext );
	} else {
		// If no file specified, grab editor's current extension and mime-type.
		$file_ext  = strtolower( pathinfo( $this->file, PATHINFO_EXTENSION ) );
		$file_mime = $this->mime_type;
	}

	// Check to see if specified mime-type is the same as type implied by
	// file extension. If so, prefer extension from file.
	if ( ! $mime_type || ( $file_mime == $mime_type ) ) {
		$mime_type = $file_mime;
		$new_ext   = $file_ext;
	}

	// Double-check that the mime-type selected is supported by the editor.
	// If not, choose a default instead.
	if ( ! $this->supports_mime_type( $mime_type ) ) {
		/**
		 * Filters default mime type prior to getting the file extension.
		 *
		 * @see wp_get_mime_types()
		 *
		 * @since 3.5.0
		 *
		 * @param string $mime_type Mime type string.
		 */
		$mime_type = apply_filters( 'image_editor_default_mime_type', $this->default_mime_type );
		$new_ext   = $this->get_extension( $mime_type );
	}

	if ( $filename ) {
		$dir = pathinfo( $filename, PATHINFO_DIRNAME );
		$ext = pathinfo( $filename, PATHINFO_EXTENSION );

		$filename = trailingslashit( $dir ) . wp_basename( $filename, ".$ext" ) . ".{$new_ext}";
	}

	return array( $filename, $new_ext, $mime_type );
}