get_the_attachment_link()
Устарела с версии 2.5.0. Больше не поддерживается и может быть удалена. Используйте wp_get_attachment_link().
Retrieve HTML content of attachment image with link.
Хуков нет.
Возвращает
Строку
.
Использование
get_the_attachment_link( $id, $fullsize, $max_dims, $permalink );
- $id(int)
- Post ID.
- $fullsize(true|false)
- Whether to use full size image.
По умолчанию: false - $max_dims(массив)
- Max image dimensions.
По умолчанию: false - $permalink(true|false)
- Whether to include permalink to image.
По умолчанию: false
Заметки
- Смотрите: wp_get_attachment_link()
Список изменений
С версии 2.0.0 | Введена. |
Устарела с 2.5.0 | Use wp_get_attachment_link() |
Код get_the_attachment_link() get the attachment link WP 6.4.1
function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) { _deprecated_function( __FUNCTION__, '2.5.0', 'wp_get_attachment_link()' ); $id = (int) $id; $_post = get_post($id); if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) return __('Missing Attachment'); if ( $permalink ) $url = get_attachment_link($_post->ID); $post_title = esc_attr($_post->post_title); $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims); return "<a href='$url' title='$post_title'>$innerHTML</a>"; }