- if ( preg_match('{\n<p>(<img [^>]*>)</p>}', $rest, $img, PREG_OFFSET_CAPTURE) ) {
- $this->img = $img[1][0];
+ if ( preg_match('{
+ \n (?: < (?: p | figure [^>]* ) >\s* )+ (<img\ [^>]*>) | \n <hr\ />
+ }x', $rest, $img, PREG_OFFSET_CAPTURE) ) {
+ if (isset($img[1])) {
+ $this->img = $img[1][0];
+ }