Update get_attachment_link() to return image URL when attachment pages are turned off.#6728
Update get_attachment_link() to return image URL when attachment pages are turned off.#6728deepakrohillas wants to merge 17 commits intoWordPress:trunkfrom
get_attachment_link() to return image URL when attachment pages are turned off.#6728Conversation
… add_action() `error.message` LIKE 'Uncaught exception 'Error' with message 'Call to undefined function add_action()' in /var/www/wp-content/plugins/hello.php:69%' AND `error.class` = 'Error' AND transactionUiName = '/wp-content/plugins/hello.php' 'request_uri': '/wp-content/plugins/hello.php'
…dolly_uncaught_exception Fix Uncaught exception Error with message 'Call to undefined function…
…PATH direct access to wp-includes/rss.php on line 19 https://core.trac.wordpress.org/ticket/61277
… return attachment url
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
… return attachment url
… return attachment url
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
peterwilsoncc
left a comment
There was a problem hiding this comment.
I think the changes you've made can be earlier in the function and bypass the check for a parent.
I'd suggest placing the new condition immediately after the call the get_post():
$post = get_post( $post );
// Return image URL if attachment pages are disabled.
if ( $post && '0' === get_option( 'wp_attachment_pages_enabled' ) ) {
return wp_get_attachment_url( $post->ID );
}This change will probably cause a few unit tests to fail as the value of get_attachment_link() will no longer meet the expected value. These tests should be updated to check the correct value is returned if the attachment pages are enabled, and if they are not.
I'd suggest duplicating the existing tests, once to run with pages enabled, and one to run with them disabled.
suggested changes done
formatting
|
@peterwilsoncc : Thanks for the review. Suggested changes has been done. |
Trac ticket: https://core.trac.wordpress.org/ticket/61133