diff --git a/wp-includes/media.php b/wp-includes/media.php
index e63e5bb..3722521 100644
a
|
b
|
function wp_embed_handler_video( $matches, $attr, $url, $rawattr ) { |
1385 | 1385 | if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] ) ) { |
1386 | 1386 | $dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] ); |
1387 | 1387 | $dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] ); |
1388 | | } elseif ( strstr( $url, home_url() ) ) { |
1389 | | $id = attachment_url_to_postid( $url ); |
1390 | | if ( ! empty( $id ) ) { |
1391 | | $meta = wp_get_attachment_metadata( $id ); |
1392 | | if ( ! empty( $meta['width'] ) ) |
1393 | | $dimensions .= sprintf( 'width="%d" ', (int) $meta['width'] ); |
1394 | | if ( ! empty( $meta['height'] ) ) |
1395 | | $dimensions .= sprintf( 'height="%d" ', (int) $meta['height'] ); |
1396 | | } |
1397 | 1388 | } |
1398 | | |
1399 | 1389 | $video = sprintf( '[video %s src="%s" /]', $dimensions, esc_url( $url ) ); |
1400 | 1390 | return apply_filters( 'wp_embed_handler_video', $video, $attr, $url, $rawattr ); |
1401 | 1391 | } |
… |
… |
function the_post_format_image( $attached_size = 'full' ) { |
2471 | 2461 | } |
2472 | 2462 | |
2473 | 2463 | /** |
2474 | | * Retrieve the post id for an attachment file URL |
2475 | | * |
2476 | | * @since 3.6.0 |
2477 | | * |
2478 | | * @param string $url Permalink to check. |
2479 | | * @return int Post ID, or 0 on failure. |
2480 | | */ |
2481 | | function attachment_url_to_postid( $url ) { |
2482 | | global $wpdb; |
2483 | | if ( preg_match( '#\.[a-zA-Z0-9]+$#', $url ) ) { |
2484 | | $id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' " . |
2485 | | "AND guid = %s", $url ) ); |
2486 | | |
2487 | | if ( ! empty( $id ) ) |
2488 | | return (int) $id; |
2489 | | } |
2490 | | |
2491 | | return 0; |
2492 | | } |
2493 | | |
2494 | | /** |
2495 | 2464 | * Retrieve the attachment post id from HTML containing an image. |
2496 | 2465 | * |
2497 | 2466 | * @since 3.6.0 |
… |
… |
function img_html_to_post_id( $html, &$matched_html = null ) { |
2509 | 2478 | |
2510 | 2479 | $matched_html = $matches[0]; |
2511 | 2480 | |
2512 | | // Look for attributes. |
2513 | | if ( ! preg_match_all( '#(src|class)=([\'"])(.+?)\2#is', $matched_html, $matches ) || empty( $matches ) ) |
| 2481 | // Look for the class attribute. |
| 2482 | if ( ! preg_match( '#class=([\'"])(.+?)\1#is', $matched_html, $matches ) || empty( $matches ) ) |
2514 | 2483 | return $attachment_id; |
2515 | 2484 | |
2516 | | $attr = array(); |
2517 | | foreach ( $matches[1] as $key => $attribute_name ) |
2518 | | $attr[ $attribute_name ] = $matches[3][ $key ]; |
2519 | | |
2520 | | if ( ! empty( $attr['class'] ) && false !== strpos( $attr['class'], 'wp-image-' ) ) |
2521 | | if ( preg_match( '#wp-image-([0-9]+)#i', $attr['class'], $matches ) ) |
| 2485 | $classes = $matches[2]; |
| 2486 | if ( ! empty( $classes ) && false !== strpos( $classes, 'wp-image-' ) ) |
| 2487 | if ( preg_match( '#wp-image-([0-9]+)#i', $classes, $matches ) ) |
2522 | 2488 | $attachment_id = absint( $matches[1] ); |
2523 | 2489 | |
2524 | | if ( ! $attachment_id && ! empty( $attr['src'] ) ) |
2525 | | $attachment_id = attachment_url_to_postid( $attr['src'] ); |
2526 | | |
2527 | 2490 | return $attachment_id; |
2528 | 2491 | } |