Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_get_attachment_link [ WordPress Function ]

wp_get_attachment_link ( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false )
Parameters:
  • (int) $id Optional. Post ID.
  • (string) $size Optional, default is 'thumbnail'. Size of image, either array or string.
  • (bool) $permalink Optional, default is false. Whether to add permalink to image.
  • (bool) $icon Optional, default is false. Whether to include icon.
  • (string) $text Optional, default is false. If string, then will be link text.
Uses:
Returns:
  • (string) HTML content.
Defined at:



Retrieve an attachment page link using an image or icon, if possible.

Source


<?php
function wp_get_attachment_link$id 0$size 'thumbnail'$permalink false$icon false$text false ) {
    
$id intval$id );
    
$_post = & get_post$id );

    if ( empty( 
$_post ) || ( '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 );

    if ( 
$text )
        
$link_text $text;
    elseif ( 
$size && 'none' != $size )
        
$link_text wp_get_attachment_image$id$size$icon );
    else
        
$link_text '';

    if ( 
trim$link_text ) == '' )
        
$link_text $_post->post_title;

    return 
apply_filters'wp_get_attachment_link'"<a href='$url' title='$post_title'>$link_text</a>"$id$size$permalink$icon$text );
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics