get_uploaded_header_images

Get the header images uploaded for the current theme.

Description

(array) get_uploaded_header_images(); 

Returns (array)


Usage

  1. if ( !function_exists( 'get_uploaded_header_images' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = get_uploaded_header_images(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/theme.php  
  1. function get_uploaded_header_images() { 
  2. $header_images = array(); 
  3.  
  4. // @todo caching 
  5. $headers = get_posts( array( 'post_type' => 'attachment', 'meta_key' => '_wp_attachment_is_custom_header', 'meta_value' => get_option('stylesheet'), 'orderby' => 'none', 'nopaging' => true ) ); 
  6.  
  7. if ( empty( $headers ) ) 
  8. return array(); 
  9.  
  10. foreach ( (array) $headers as $header ) { 
  11. $url = esc_url_raw( wp_get_attachment_url( $header->ID ) ); 
  12. $header_data = wp_get_attachment_metadata( $header->ID ); 
  13. $header_index = $header->ID; 
  14.  
  15. $header_images[$header_index] = array(); 
  16. $header_images[$header_index]['attachment_id'] = $header->ID; 
  17. $header_images[$header_index]['url'] = $url; 
  18. $header_images[$header_index]['thumbnail_url'] = $url; 
  19. $header_images[$header_index]['alt_text'] = get_post_meta( $header->ID, '_wp_attachment_image_alt', true ); 
  20.  
  21. if ( isset( $header_data['width'] ) ) 
  22. $header_images[$header_index]['width'] = $header_data['width']; 
  23. if ( isset( $header_data['height'] ) ) 
  24. $header_images[$header_index]['height'] = $header_data['height']; 
  25.  
  26. return $header_images;