862 | | if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) { |
| 862 | $matches = array(); |
| 863 | $regex = '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is'; |
| 864 | preg_match( $regex, $content, $matches ); |
| 865 | |
| 866 | /** |
| 867 | * Filter the content and caption for use in the caption shortcode. |
| 868 | * |
| 869 | * If the filtered array `$matches` is empty, an old-style caption attribute |
| 870 | * will be assumed. |
| 871 | * |
| 872 | * @since 4.4.0 |
| 873 | * |
| 874 | * @param array $matches The default result of `preg_match`. |
| 875 | * @param string $content The content included in the caption shortcode (including the image). |
| 876 | * @param string $regex The regular expression capturing the image and the caption attribute. |
| 877 | * |
| 878 | * @return array $matches { |
| 879 | * Array corresponding to the result of `preg_match`. |
| 880 | * |
| 881 | * @type string 1 The new `$content` used in the shortcode (i.e. the `<img>` tag). |
| 882 | * @type string 2 The caption (set as `$attr['caption']`. |
| 883 | * } |
| 884 | */ |
| 885 | $matches = apply_filters( 'img_caption_shortcode_content', $matches, $content, $regex ); |
| 886 | |
| 887 | if ( ! empty ( $matches ) ) { |