Make WordPress Core

Changeset 23992


Ignore:
Timestamp:
04/14/2013 04:59:52 PM (11 years ago)
Author:
markjaquith
Message:

Link post format images if a URL is provided. Make the URL available via get_the_post_format_url().

props wonderboymusic, obenland. fixes #23964.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r23989 r23992  
    24012401
    24022402    $meta = get_post_format_meta( $post->ID );
     2403
     2404    $link_fmt = '%s';
     2405    if ( ! empty( $meta['url'] ) )
     2406        $link_fmt = '<a href="' . esc_url( $meta['url'] ) . '">%s</a>';
     2407
    24032408    if ( ! empty( $meta['image'] ) ) {
    2404         $post->format_content = wp_get_attachment_image( $meta['image'], $attached_size );
     2409        $post->format_content = sprintf( $link_fmt, wp_get_attachment_image( $meta['image'], $attached_size ) );
    24052410        return $post->format_content;
    24062411    }
     
    24132418        $urls = array();
    24142419        foreach ( $sizes as $size ) {
    2415             $urls[] = reset( wp_get_attachment_image_src( $media->ID, $size ) );
    2416             $urls[] = get_attachment_link( $media->ID );
     2420            $image = wp_get_attachment_image_src( $media->ID, $size );
     2421            if ( $image ) {
     2422                $urls[] = reset( $image );
     2423                $urls[] = get_attachment_link( $media->ID );
     2424            }
    24172425        }
    24182426
     
    24442452
    24452453        $post->split_content = $content;
    2446         $post->format_content = wp_get_attachment_image( $media->ID, $attached_size );
     2454        $image = wp_get_attachment_image( $media->ID, $attached_size );
     2455        $post->format_content = sprintf( $link_fmt, $image );
    24472456        return $post->format_content;
    24482457    }
     
    24532462        $html = reset( $htmls );
    24542463        $post->split_content = $content;
    2455         $post->format_content = $html;
     2464        $post->format_content = sprintf( $link_fmt, $html );
    24562465        return $post->format_content;
    24572466    }
  • trunk/wp-includes/post-formats.php

    r23978 r23992  
    708708        return '';
    709709
    710     if ( in_array( get_post_format( $post->ID ), array( 'link', 'quote' ) ) ) {
     710    if ( in_array( get_post_format( $post->ID ), array( 'image', 'link', 'quote' ) ) ) {
    711711        $meta = get_post_format_meta( $post->ID );
    712712        if ( ! empty( $meta['url'] ) )
Note: See TracChangeset for help on using the changeset viewer.