[wp-trac] [WordPress Trac] #44655: Introduce alternative srcset option for custom logo

WordPress Trac noreply at wordpress.org
Fri Jul 27 15:40:15 UTC 2018


#44655: Introduce alternative srcset option for custom logo
-------------------------+------------------------------
 Reporter:  mrmadhat     |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Media        |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+------------------------------

Comment (by mrmadhat):

 Replying to [comment:1 swissspidy]:
 > Have you tried `add_image_size()` with both 186x38 and 372x76? If
 WordPress sees that the image is available in both sizes, it will print
 the srcset accordingly.

 I have both 186x38 and 372x76 defined:

 with:

 {{{#!php
 <?php
     add_theme_support( 'custom-logo', array(
         'height'      => 38,
         'width'       => 186,
         'flex-width'  => true,
         'flex-height' => true,
     ));
 }}}

 I get the following:


 {{{
 <img width="558" height="114"
     src="http://www.domain.co.uk/wp-content/uploads/2018/07/img.png" class
 ="custom-logo" alt="test" itemprop="logo"
     srcset="
         http://www.domain.co.uk/wp-content/uploads/2018/07/img.png 558w,
         http://www.domain.co.uk/wp-content/uploads/2018/07/img-350x72.png
 350w,
         http://www.domain.co.uk/wp-content/uploads/2018/07/img-186x38.png
 186w,
         http://www.domain.co.uk/wp-content/uploads/2018/07/img-372x76.png
 372w"
     sizes="(max-width: 558px) 100vw, 558px">
 }}}

 The image is still allowed to reach it's original width and height if the
 container allows and no styling has been applied to modify width or
 height.

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


More information about the wp-trac mailing list