@@ 202-211 (lines=10) @@ | ||
199 | add_filter( 'media_send_to_editor', 'videopress_media_send_to_editor', 10, 3 ); |
|
200 | function videopress_media_send_to_editor( $html, $id, $attachment ) { |
|
201 | $videopress_guid = get_post_meta( $id, 'videopress_guid', true ); |
|
202 | if ( $videopress_guid && videopress_is_valid_guid( $videopress_guid ) ) { |
|
203 | if ( '[video ' === substr( $html, 0, 7 ) ) { |
|
204 | $html = sprintf( '[videopress %1$s]', esc_attr( $videopress_guid ) ); |
|
205 | ||
206 | } elseif ( '<a href=' === substr( $html, 0, 8 ) ) { |
|
207 | // We got here because `wp_attachment_is()` returned false for |
|
208 | // video, because there isn't a local copy of the file. |
|
209 | $html = sprintf( '[videopress %1$s]', esc_attr( $videopress_guid ) ); |
|
210 | } |
|
211 | } |
|
212 | return $html; |
|
213 | } |
@@ 202-211 (lines=10) @@ | ||
199 | add_filter( 'media_send_to_editor', 'videopress_media_send_to_editor', 10, 3 ); |
|
200 | function videopress_media_send_to_editor( $html, $id, $attachment ) { |
|
201 | $videopress_guid = get_post_meta( $id, 'videopress_guid', true ); |
|
202 | if ( $videopress_guid && videopress_is_valid_guid( $videopress_guid ) ) { |
|
203 | if ( '[video ' === substr( $html, 0, 7 ) ) { |
|
204 | $replace = sprintf( ' videopress_guid="%1$s"][/video]', esc_attr( $videopress_guid ) ); |
|
205 | $html = str_replace( '][/video]', $replace, $html ); |
|
206 | } elseif ( '<a href=' === substr( $html, 0, 8 ) ) { |
|
207 | // We got here because `wp_attachment_is()` returned false for |
|
208 | // video, because there isn't a local copy of the file. |
|
209 | $html = sprintf( '[videopress %1$s]', esc_attr( $videopress_guid ) ); |
|
210 | } |
|
211 | } |
|
212 | return $html; |
|
213 | } |