Core Function
View Source on Trac ↗ wp_get_attachment_link()
wp_get_attachment_link(
mixed $post = 0,
mixed $size = 'thumbnail',
mixed $permalink = false,
mixed $icon = false,
mixed $text = false,
mixed $attr = ''
) Retrieves an attachment page link using an image or icon, if possible.
Parameters 4 required
| Name / Type | Description |
|---|---|
| (int | | WP_Post) $post Optional. Post ID or post object. Required |
| mixed | (string | int[]) $size Optional. Image size. Accepts any registered image size name, or an array of width and height values in pixels (in that order). Default 'thumbnail'. Required |
| $permalink bool | Optional. Whether to add permalink to image. Default false. |
| $icon bool | Optional. Whether the attachment is an icon. Default false. |
| mixed | (string | false) $text Optional. Link text to use. Activated by passing a string, false otherwise. Default false. Required |
| (array | | string) $attr Optional. Array or string of attributes. Default empty. Required |
Return Value
(string)
HTML content.
Function Information
Since Version
2.5.0
Source File
wp-includes/post-template.php
Advertisement