| | 9 | |
| | 10 | e.g. |
| | 11 | {{{#!php |
| | 12 | <?php |
| | 13 | $url = ( empty ($attachment['url'] ) ) ? '' : $attachment['url']; |
| | 14 | $rel = ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url ) ? ' rel="attachment wp-att-' . $id . '"' : ''; |
| | 15 | |
| | 16 | remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' ); |
| | 17 | |
| | 18 | if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) { |
| | 19 | $align = isset( $attachment['align'] ) ? $attachment['align'] : 'none'; |
| | 20 | $size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium'; |
| | 21 | $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : ''; |
| | 22 | $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : ''; |
| | 23 | $title = ''; // We no longer insert title tags into <img> tags, as they are redundant. |
| | 24 | $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt ); |
| | 25 | } elseif ( 'video' === substr( $post->post_mime_type, 0, 5 ) || 'audio' === substr( $post->post_mime_type, 0, 5 ) ) { |
| | 26 | $html = stripslashes_deep( $_POST['html'] ); |
| | 27 | } else { |
| | 28 | $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; |
| | 29 | if ( $url ) { |
| | 30 | $html = '<a href="' . esc_url( $url ) . '"' . $rel . '>' . $html . '</a>'; |
| | 31 | } |
| | 32 | } |
| | 33 | }}} |