On this page
image_link_input_fields( WP_Post $post, string $url_type = '' ): string
Retrieves HTML for the Link URL buttons with the default link type as specified.
Parameters
$postWP_Post Required$url_typestring Optional-
Default:
''
Return
string
Source
File: wp-admin/includes/media.php. View all references
function image_link_input_fields( $post, $url_type = '' ) {
$file = wp_get_attachment_url( $post->ID );
$link = get_attachment_link( $post->ID );
if ( empty( $url_type ) ) {
$url_type = get_user_setting( 'urlbutton', 'post' );
}
$url = '';
if ( 'file' === $url_type ) {
$url = $file;
} elseif ( 'post' === $url_type ) {
$url = $link;
}
return "
<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr( $url ) . "' /><br />
<button type='button' class='button urlnone' data-link-url=''>" . __( 'None' ) . "</button>
<button type='button' class='button urlfile' data-link-url='" . esc_url( $file ) . "'>" . __( 'File URL' ) . "</button>
<button type='button' class='button urlpost' data-link-url='" . esc_url( $link ) . "'>" . __( 'Attachment Post URL' ) . '</button>
';
}
Related
Uses
| Uses | Description |
|---|---|
| get_attachment_link() wp-includes/link-template.php | Retrieves the permalink for an attachment. |
| get_user_setting() wp-includes/option.php | Retrieves user interface setting value based on setting name. |
| wp_get_attachment_url() wp-includes/post.php | Retrieves the URL for an attachment. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| esc_attr() wp-includes/formatting.php | Escaping for HTML attributes. |
| esc_url() wp-includes/formatting.php | Checks and cleans a URL. |
Used By
| Used By | Description |
|---|---|
| get_attachment_fields_to_edit() wp-admin/includes/media.php | Retrieves the attachment fields to edit form fields. |
Changelog
| Version | Description |
|---|---|
| 2.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/image_link_input_fields