wp_get_attachment_link example

if ( empty( $attachments ) ) {
        return '';
    }

    if ( is_feed() ) {
        $output = "\n";
        foreach ( $attachments as $att_id => $attachment ) {
            if ( ! empty( $atts['link'] ) ) {
                if ( 'none' === $atts['link'] ) {
                    $output .= wp_get_attachment_image( $att_id$atts['size'], false, $attr );
                } else {
                    $output .= wp_get_attachment_link( $att_id$atts['size'], false );
                }
            } else {
                $output .= wp_get_attachment_link( $att_id$atts['size'], true );
            }
            $output .= "\n";
        }
        return $output;
    }

    $itemtag    = tag_escape( $atts['itemtag'] );
    $captiontag = tag_escape( $atts['captiontag'] );
    

function the_attachment_link( $post = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
    if ( ! empty( $deprecated ) ) {
        _deprecated_argument( __FUNCTION__, '2.5.0' );
    }

    if ( $fullsize ) {
        echo wp_get_attachment_link( $post, 'full', $permalink );
    } else {
        echo wp_get_attachment_link( $post, 'thumbnail', $permalink );
    }
}

/** * Retrieves an attachment page link using an image or icon, if possible. * * @since 2.5.0 * @since 4.4.0 The `$post` parameter can now accept either a post ID or `WP_Post` object. * * @param int|WP_Post $post Optional. Post ID or post object. * @param 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'. * @param bool $permalink Optional. Whether to add permalink to image. Default false. * @param bool $icon Optional. Whether the attachment is an icon. Default false. * @param string|false $text Optional. Link text to use. Activated by passing a string, false otherwise. * Default false. * @param array|string $attr Optional. Array or string of attributes. Default empty. * @return string HTML content. */
Home | Imprint | This part of the site doesn't use cookies.