WordPress.org

Make WordPress Core

Ticket #24609: wp_ajax_send_attachment_to_editor.diff

File wp_ajax_send_attachment_to_editor.diff, 1.1 KB (added by derekspringer, 5 years ago)

Patch for wp_ajax_send_attachment_to_editor() function to allow inserting links to media instead of shortcode.

  • 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 = 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