WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/21/2020 11:12:22 PM (16 months ago)
Author:
SergeyBiryukov
Message:

Widgets: Make sure image widgets with custom image size render captions.

Props kasparsd, JavierCasares, audrasjb.
Fixes #50160.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/widgets/media-image-widget.php

    r48464 r48557  
    586586        $this->assertContains( 'class="wp-caption alignnone"', $output );
    587587        $this->assertContains( '<p class="wp-caption-text">Custom caption</p>', $output );
     588
     589        // Attachments with custom sizes can render captions.
     590        ob_start();
     591        $widget->render_media(
     592            array(
     593                'attachment_id' => $attachment_id,
     594                'size'          => 'custom',
     595                'width'         => '300',
     596                'height'        => '200',
     597                'caption'       => 'Caption for an image with custom size',
     598            )
     599        );
     600        $output = ob_get_clean();
     601        $this->assertContains( 'style="width: 310px"', $output );
     602        $this->assertContains( '<p class="wp-caption-text">Caption for an image with custom size</p>', $output );
    588603    }
    589604
Note: See TracChangeset for help on using the changeset viewer.