| 1461 | | if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) { |
| | 1461 | $matches = array(); |
| | 1462 | $regex = '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is'; |
| | 1463 | preg_match( $regex, $content, $matches ); |
| | 1464 | |
| | 1465 | /** |
| | 1466 | * Filter the content and caption for use in the caption shortcode. |
| | 1467 | * |
| | 1468 | * If the filtered array `$matches` is empty, an old-style caption attribute |
| | 1469 | * will be assumed. |
| | 1470 | * |
| | 1471 | * @since x.x.x |
| | 1472 | * |
| | 1473 | * @param array $matches The default result of `preg_match`. |
| | 1474 | * @param string $content The content included in the caption shortcode (including the image). |
| | 1475 | * @param string $regex The regular expression capturing the image and the caption attribute. |
| | 1476 | * |
| | 1477 | * @return array $matches { |
| | 1478 | * Array corresponding to the result of `preg_match`. |
| | 1479 | * |
| | 1480 | * @type string 1 The new `$content` used in the shortcode (i.e. the `<img>` tag). |
| | 1481 | * @type string 2 The caption (set as `$attr['caption']`. |
| | 1482 | * } |
| | 1483 | */ |
| | 1484 | $matches = apply_filters( 'img_caption_shortcode_content', $matches, $content, $regex ); |
| | 1485 | |
| | 1486 | if ( ! empty ( $matches ) ) { |