Making WordPress.org

Changeset 13670


Ignore:
Timestamp:
05/08/2024 03:56:04 AM (3 months ago)
Author:
dufresnesteven
Message:

Plugin-directory: Update plugin banner html to better support display on lower DPI screens.

See #7620

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php

    r13626 r13670  
    495495        switch ( $output ) {
    496496            case 'html':
    497                 $id    = "plugin-banner-{$plugin->post_name}";
    498                 $html  = "<style type='text/css'>";
    499                 $html .= "#{$id} { background-image: url('{$banner}'); }";
    500                 if ( ! empty( $banner_2x ) ) {
    501                     $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 120dpi) { #{$id} { background-image: url('{$banner_2x}'); } }";
    502                 }
    503                 $html .= '</style>';
    504                 $html .= "<div class='plugin-banner' id='{$id}'></div>";
    505 
    506                 return $html;
     497                return sprintf(
     498                    '<div class="plugin-banner" id="%1$s"><img decoding="async" fetchpriority="high" src="%2$s" %3$s %4$s></div>',
     499                    esc_attr( "plugin-banner-{$plugin->post_name}" ),
     500                    esc_url( $banner ),
     501                    ! empty( $banner_2x ) ? "srcset='" . esc_url( $banner ) . " 772w, " . esc_url( $banner_2x ) . " 1544w'" : '',
     502                    ! empty( $banner_2x ) ? 'sizes="(min-width: 900px) 1544px, 772px"' : ''
     503                );
     504
    507505                break;
    508506
Note: See TracChangeset for help on using the changeset viewer.