[wp-trac] [WordPress Trac] #45708: Allow retrieving adjacent image link markup without echoing it
WordPress Trac
noreply at wordpress.org
Thu Jun 3 15:16:40 UTC 2021
#45708: Allow retrieving adjacent image link markup without echoing it
-------------------------------------------------+-------------------------
Reporter: flixos90 | Owner:
| hellofromTonya
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 5.8
Component: Media | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests has- | Focuses: template
testing-info |
-------------------------------------------------+-------------------------
Changes (by hellofromTonya):
* keywords: has-patch has-unit-tests => has-patch has-unit-tests has-
testing-info
Comment:
== Steps to manually test
To manually test the original functions still work with output buffering,
do these steps:
- Add at least 3 images to the Media Library
- Create a `wp-content/mu-plugins/test.php` file
- Add this test code:
{{{#!php
<?php
add_filter( 'the_content', 'test_45708' );
function test_45708( $content ) {
ob_start();
previous_image_link( false, '← Previous Image' );
$previous_image_link = ob_get_clean();
ob_start();
next_image_link( false, 'Next Image →' );
$next_image_link = ob_get_clean();
$nav = <<<HTML
<nav id="image-navigation" class="navigation" role="navigation">
<span class="previous-image">$previous_image_link</span>
<span class="next-image">$next_image_link</span>
</nav>
HTML;
return $content . $nav;
}
}}}
- View one of the images by going to `Media` > Select an image > `View`
Notice the navigation links under the image:
← Previous Image Next Image →
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45708#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list