get_attachment_link
get_attachment_link ( $post = null, $leavename = false )
Parameters:- (int|WP_Post) post Optional. Post ID or object. Default uses the global `$post`.
- (bool) leavename Optional. Whether to keep the page name. Default false.
Returns:- (string) The attachment permalink.
Defined at: - Introduced in WordPress: 2.0.0
- Deprecated in WordPress: —
Description
Retrieves the permalink for an attachment.This can be used in the WordPress Loop or outside of it.