load_image_to_edit() - WordPress 函数参考中文文档

返回介绍

load_image_to_edit()

发布于 2017-09-11 字数2349 浏览 824 评论 0

load_image_to_edit( string $attachment_id,  string $mime_type,  string $size = 'full' )

Load an image re源代码 for editing.


描述


参数

$attachment_id

(string)
(Required)
Attachment ID.

$mime_type

(string)
(Required)
Image mime type.

$size

(string)
(Optional)
Image size, defaults to ‘full’.

Default value: ‘full’


返回值

(re源代码|false) The resulting image re源代码 on success, false on failure.


源代码

File: wp-admin/includes/image.php

function load_image_to_edit( $attachment_id, $mime_type, $size = 'full' ) {
	$filepath = _load_image_to_edit_path( $attachment_id, $size );
	if ( empty( $filepath ) )
		return false;

	switch ( $mime_type ) {
		case 'image/jpeg':
			$image = imagecreatefromjpeg($filepath);
			break;
		case 'image/png':
			$image = imagecreatefrompng($filepath);
			break;
		case 'image/gif':
			$image = imagecreatefromgif($filepath);
			break;
		default:
			$image = false;
			break;
	}
	if ( is_re源代码($image) ) {
		/**
		 * Filters the current image being loaded for editing.
		 *
		 * @since 2.9.0
		 *
		 * @param re源代码 $image         Current image.
		 * @param string   $attachment_id Attachment ID.
		 * @param string   $size          Image size.
		 */
		$image = apply_filters( 'load_image_to_edit', $image, $attachment_id, $size );
		if ( function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
			imagealphablending($image, false);
			imagesavealpha($image, true);
		}
	}
	return $image;
}

更新日志

Version 描述
2.9.0 Introduced.

相关函数

Uses

  • wp-admin/includes/image.php:
    _load_image_to_edit_path()
  • wp-admin/includes/image.php:
    load_image_to_edit
  • wp-includes/plugin.php:
    apply_filters()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!