Make WordPress Core


Ignore:
Timestamp:
03/04/2008 04:21:37 AM (17 years ago)
Author:
matt
Message:

New functions for attachment image display, fixes #6086. Hat tip: tellyworth.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post-template.php

    r7135 r7149  
    363363//
    364364
    365 function the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
    366     echo get_the_attachment_link($id, $fullsize, $max_dims, $permalink);
    367 }
    368 
     365function the_attachment_link($id = 0, $fullsize = false, $deprecated = false, $permalink = false) {
     366    if ( $fullsize )
     367        echo wp_get_attachment_link($id, 'full', $permalink);
     368    else
     369        echo wp_get_attachment_link($id, 'thumbnail', $permalink);
     370}
     371
     372// get an attachment page link using an image or icon if possible
     373function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false) {
     374    $_post = & get_post( intval($id) );
     375
     376    if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
     377        return __('Missing Attachment');
     378
     379    if ( $permalink )
     380        $url = get_attachment_link($_post->ID);
     381
     382    $post_title = attribute_escape($_post->post_title);
     383
     384    $link_text = wp_get_attachment_image($attachment_id, $size);
     385    if ( !$link_text )
     386        $link_text = $_post->post_title;
     387
     388    return "<a href='$url' title='$post_title'>$link_text</a>";
     389
     390}
     391
     392// deprecated - use wp_get_attachment_link()
    369393function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
    370394    $id = (int) $id;
     
    383407}
    384408
     409
     410// deprecated: use wp_get_attachment_image_src()
    385411function get_attachment_icon_src( $id = 0, $fullsize = false ) {
    386412    $id = (int) $id;
     
    414440}
    415441
     442// deprecated: use wp_get_attachment_image()
    416443function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
    417444    $id = (int) $id;
    418445    if ( !$post = & get_post($id) )
    419446        return false;
    420 
     447       
    421448    if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
    422449        return false;
     
    457484}
    458485
     486// deprecated: use wp_get_attachment_image()
    459487function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
    460488    $id = (int) $id;
     
    473501function prepend_attachment($content) {
    474502    $p = '<p class="attachment">';
    475     $p .= get_the_attachment_link(false, true, array(400, 300));
     503    // show the medium sized image representation of the attachment if available, and link to the raw file
     504    $p .= wp_get_attachment_link(0, 'medium', false);
    476505    $p .= '</p>';
    477506    $p = apply_filters('prepend_attachment', $p);
Note: See TracChangeset for help on using the changeset viewer.