Make WordPress Core

Ticket #24449: wp_ajax_send_attachment_to_editor.v2.diff

File wp_ajax_send_attachment_to_editor.v2.diff, 1.2 KB (added by derekspringer, 13 years ago)

Updated version of the patch which uses the title of the file when linking to the media if it's set, otherwise falls back to the basename of the file.

  • wp-admin/includes/ajax-actions.php

     
    19921992                $url = $attachment['url'];
    19931993                if ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url )
    19941994                        $rel = ' rel="attachment wp-att-' . $id . '"';
     1995                if ( empty( $html ) )
     1996                        $html = ! empty( $post->post_title ) ? $post->post_title : basename( esc_url( $url ) );
    19951997                $html = '<a href="' . esc_url( $url ) . '"' . $rel . '>' . $html . '</a>';
    19961998        }
    19971999
     
    20042006                $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : '';
    20052007                $title = ''; // We no longer insert title tags into <img> tags, as they are redundant.
    20062008                $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt );
    2007         } elseif ( 'video' === substr( $post->post_mime_type, 0, 5 ) || 'audio' === substr( $post->post_mime_type, 0, 5 ) ) {
     2009        } elseif ( empty( $html ) && ( 'video' === substr( $post->post_mime_type, 0, 5 ) || 'audio' === substr( $post->post_mime_type, 0, 5 ) ) ) {
    20082010                $html = stripslashes_deep( $_POST['html'] );
    20092011        }
    20102012