WordPress.org

Make WordPress Core

Ticket #23649: 23649.diff

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

     
    15111511        width: auto;
    15121512}
    15131513
     1514.blog .format-gallery .gallery-item .portrait img,
     1515.archive .format-gallery .gallery-item .portrait img,
     1516.search .format-gallery .gallery-item .portrait img {
     1517        height: auto;
     1518        max-height: 1000%;
     1519        max-width: 148px;
     1520        width: 100%;
     1521}
     1522
    15141523.blog .format-gallery .gallery-item:first-child,
    15151524.archive .format-gallery .gallery-item:first-child,
    15161525.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.