WordPress.org

Make WordPress Core

Ticket #23649: 23649.1.diff

File 23649.1.diff, 1.8 KB (added by obenland, 5 years ago)
  • wp-content/themes/twentythirteen/style.css

     
    15161516.search .format-gallery .gallery-item img {
    15171517        height: 100%;
    15181518        max-height: 148px;
    1519         max-width: 1000%;
     1519        max-width: none;
    15201520        width: auto;
    15211521}
    15221522
     1523.blog .format-gallery .gallery-item .portrait img,
     1524.archive .format-gallery .gallery-item .portrait img,
     1525.search .format-gallery .gallery-item .portrait img {
     1526        height: auto;
     1527        max-height: none;
     1528        max-width: 148px;
     1529        width: 100%;
     1530}
     1531
    15231532.blog .format-gallery .gallery-item:first-child,
    15241533.archive .format-gallery .gallery-item:first-child,
    15251534.search .format-gallery .gallery-item:first-child {
  • wp-content/themes/twentythirteen/functions.php

     
    486486endif;
    487487
    488488/**
     489 * Adds a class to the attachment link so portrait images can be displayed
     490 * correctly in the featured gallery.
     491 *
     492 * @since Twenty Thirteen 1.0
     493 *
     494 * @param string $link Attachment link
     495 * @param int $id Attachment ID
     496 * @return string
     497 */
     498function twentythirteen_get_attachment_link( $link, $id ) {
     499
     500        if ( has_post_format( 'gallery' ) && ! is_single() ) {
     501                $image = wp_get_attachment_metadata( $id );
     502                if ( $image['height'] > $image['width'] )
     503                        $link = str_replace( '<a ', '<a class="portrait" ', $link );
     504        }
     505
     506        return $link;
     507}
     508add_filter( 'wp_get_attachment_link', 'twentythirteen_get_attachment_link', 10, 2 );
     509
     510/**
    489511 * Extends the default WordPress body class to denote:
    490512 * 1. Custom fonts enabled.
    491513 * 2. Single or multiple authors.