[wp-trac] [WordPress Trac] #21389: Retina theme custom headers

WordPress Trac noreply at wordpress.org
Wed Oct 21 03:38:19 UTC 2015


#21389: Retina theme custom headers
-------------------------------+------------------------
 Reporter:  nacin              |       Owner:  joemcgill
     Type:  feature request    |      Status:  assigned
 Priority:  normal             |   Milestone:  4.4
Component:  Customize          |     Version:
 Severity:  normal             |  Resolution:
 Keywords:  responsive-images  |     Focuses:
-------------------------------+------------------------

Comment (by joemcgill):

 As @benknight mentioned, `get_header_image()` just returns a url for a
 `src` attribute. However, the customizer creates a new image attachment
 including intermediate sizes when you set a custom header image, which
 means that since [changeset:"34855"] you can produce the responsive markup
 like this (line breaks for readability only):


 {{{
 <img src="<?php header_image(); ?>"
  srcset="<?php echo esc_attr(wp_get_attachment_image_srcset(
 get_custom_header()->attachment_id, 'full'); ?>"
  sizes="{customize as needed}"
  width="<?php echo esc_attr( get_custom_header()->width ); ?>"
  height="<?php echo esc_attr( get_custom_header()->height ); ?>"
  alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"
 />
 }}}

 I imagine you could often simplify this pattern a bit and do something
 like...

 {{{
 <?php wp_get_attachment_image( get_custom_header()->attachment_id, 'full'
 ); ?>
 }}}

 ...which would automatically have `srcset` and `sizes` attributes added,
 as long as additional intermediate sizes are available to populate the
 `srcset`.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/21389#comment:23>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list