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

返回介绍

get_uploaded_header_images()

发布于 2017-09-11 字数2730 浏览 793 评论 0

get_uploaded_header_images()

Get the header images uploaded for the current theme.


描述


返回值

(array)


源代码

File: wp-includes/theme.php

function get_uploaded_header_images() {
	$header_images = array();

	// @todo caching
	$headers = get_posts( array( 'post_type' => 'attachment', 'meta_key' => '_wp_attachment_is_custom_header', 'meta_value' => get_option('stylesheet'), 'orderby' => 'none', 'nopaging' => true ) );

	if ( empty( $headers ) )
		return array();

	foreach ( (array) $headers as $header ) {
		$url = esc_url_raw( wp_get_attachment_url( $header->ID ) );
		$header_data = wp_get_attachment_metadata( $header->ID );
		$header_index = $header->ID;

		$header_images[$header_index] = array();
		$header_images[$header_index]['attachment_id'] = $header->ID;
		$header_images[$header_index]['url'] =  $url;
		$header_images[$header_index]['thumbnail_url'] = $url;
		$header_images[$header_index]['alt_text'] = get_post_meta( $header->ID, '_wp_attachment_image_alt', true );

		if ( isset( $header_data['width'] ) )
			$header_images[$header_index]['width'] = $header_data['width'];
		if ( isset( $header_data['height'] ) )
			$header_images[$header_index]['height'] = $header_data['height'];
	}

	return $header_images;
}

更新日志

Version 描述
3.2.0 Introduced.

相关函数

Uses

  • wp-includes/formatting.php:
    esc_url_raw()
  • wp-includes/option.php:
    get_option()
  • wp-includes/post.php:
    wp_get_attachment_url()
  • wp-includes/post.php:
    wp_get_attachment_metadata()
  • wp-includes/post.php:
    get_posts()
  • wp-includes/post.php:
    get_post_meta()
  • Show 1 more use
    Hide more uses


Used By

  • wp-admin/includes/template.php:
    _media_states()
  • wp-admin/custom-header.php:
    Custom_Image_Header::get_uploaded_header_images()
  • wp-admin/custom-header.php:
    Custom_Image_Header::step_1()
  • wp-admin/custom-header.php:
    Custom_Image_Header::set_header_image()
  • wp-admin/custom-header.php:
    Custom_Image_Header::show_header_selector()
  • wp-includes/theme.php:
    _get_random_header_data()
  • Show 1 more used by
    Hide more used by


User Contributed Notes

上一篇:get_udims()

下一篇:get_upload_iframe_src()

发布评论

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

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