返回介绍

_load_image_to_edit_path()

发布于 2017-09-11 13:26:20 字数 4024 浏览 978 评论 0 收藏 0

Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_load_image_to_edit_path( string $attachment_id,  string $size = 'full' )

Retrieve the path or url of an attachment’s attached file.


description

If the attached file is not present on the local filesystem (usually due to replication plugins), then the url of the file is returned if url fopen is supported.


参数

$attachment_id

(string) (Required) Attachment ID.

$size

(string) (Optional) Image size, defaults to 'full'.

Default value: 'full'


返回值

(string|false) File path or url on success, false on failure.


源代码

File: wp-admin/includes/image.php

function _load_image_to_edit_path( $attachment_id, $size = 'full' ) {
	$filepath = get_attached_file( $attachment_id );

	if ( $filepath && file_exists( $filepath ) ) {
		if ( 'full' != $size && ( $data = image_get_intermediate_size( $attachment_id, $size ) ) ) {
			/**
			 * Filters the path to the current image.
			 *
			 * The filter is evaluated for all image sizes except 'full'.
			 *
			 * @since 3.1.0
			 *
			 * @param string $path          Path to the current image.
			 * @param string $attachment_id Attachment ID.
			 * @param string $size          Size of the image.
			 */
			$filepath = apply_filters( 'load_image_to_edit_filesystempath', path_join( dirname( $filepath ), $data['file'] ), $attachment_id, $size );
		}
	} elseif ( function_exists( 'fopen' ) && true == ini_get( 'allow_url_fopen' ) ) {
		/**
		 * Filters the image URL if not in the local filesystem.
		 *
		 * The filter is only evaluated if fopen is enabled on the server.
		 *
		 * @since 3.1.0
		 *
		 * @param string $image_url     Current image URL.
		 * @param string $attachment_id Attachment ID.
		 * @param string $size          Size of the image.
		 */
		$filepath = apply_filters( 'load_image_to_edit_attachmenturl', wp_get_attachment_url( $attachment_id ), $attachment_id, $size );
	}

	/**
	 * Filters the returned path or URL of the current image.
	 *
	 * @since 2.9.0
	 *
	 * @param string|bool $filepath      File path or URL to current image, or false.
	 * @param string      $attachment_id Attachment ID.
	 * @param string      $size          Size of the image.
	 */
	return apply_filters( 'load_image_to_edit_path', $filepath, $attachment_id, $size );
}

更新日志

Versiondescription
3.4.0Introduced.

相关函数

Uses

  • wp-admin/includes/image.php: load_image_to_edit_filesystempath
  • wp-admin/includes/image.php: load_image_to_edit_attachmenturl
  • wp-admin/includes/image.php: load_image_to_edit_path
  • wp-includes/functions.php: path_join()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/media.php: image_get_intermediate_size()
  • wp-includes/post.php: wp_get_attachment_url()
  • wp-includes/post.php: get_attached_file()
  • Show 3 more uses Hide more uses

Used By

  • wp-admin/includes/image-edit.php: stream_preview_image()
  • wp-admin/includes/image-edit.php: wp_save_image()
  • wp-admin/includes/image.php: _copy_image_file()
  • wp-admin/includes/image.php: load_image_to_edit()
  • wp-admin/includes/image.php: wp_crop_image()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文