@@ -1078,7 +1078,7 @@ public function parseH(\DOMElement $e, $is_backcompat = false, $has_nested_mf =
10781078 $ photo = $ this ->parseImpliedPhoto ($ e );
10791079
10801080 if ($ photo !== false ) {
1081- $ return ['photo ' ][] = $ this -> resolveUrl ( $ photo) ;
1081+ $ return ['photo ' ][] = $ photo ;
10821082 }
10831083
10841084 }
@@ -1155,38 +1155,37 @@ public function parseH(\DOMElement $e, $is_backcompat = false, $has_nested_mf =
11551155 */
11561156 public function parseImpliedPhoto (\DOMElement $ e ) {
11571157
1158+ // img.h-x[src]
11581159 if ($ e ->tagName == 'img ' ) {
1159- return $ e ->getAttribute ('src ' );
1160+ return $ this -> resolveUrl ( $ e ->getAttribute ('src ' ) );
11601161 }
11611162
1163+ // object.h-x[data]
11621164 if ($ e ->tagName == 'object ' && $ e ->hasAttribute ('data ' )) {
1163- return $ e ->getAttribute ('data ' );
1165+ return $ this -> resolveUrl ( $ e ->getAttribute ('data ' ) );
11641166 }
11651167
11661168 $ xpaths = array (
1167- './img ' ,
1168- './object ' ,
1169- './*[not(contains(concat(" ", @class), " h-"))]/img[count(preceding-sibling::img)+count(following-sibling::img)=0] ' ,
1170- './*[not(contains(concat(" ", @class), " h-"))]/object[count(preceding-sibling::object)+count(following-sibling::object)=0] ' ,
1169+ // .h-x>img[src]:only-of-type:not[.h-*]
1170+ './img[not(contains(concat(" ", @class), " h-")) and count(../img) = 1 and @src] ' ,
1171+ // .h-x>object[data]:only-of-type:not[.h-*]
1172+ './object[not(contains(concat(" ", @class), " h-")) and count(../object) = 1 and @data] ' ,
1173+ // .h-x>:only-child:not[.h-*]>img[src]:only-of-type:not[.h-*]
1174+ './*[not(contains(concat(" ", @class), " h-")) and count(../*) = 1 and count(img) = 1]/img[not(contains(concat(" ", @class), " h-")) and @src] ' ,
1175+ // .h-x>:only-child:not[.h-*]>object[data]:only-of-type:not[.h-*]
1176+ './*[not(contains(concat(" ", @class), " h-")) and count(../*) = 1 and count(object) = 1]/object[not(contains(concat(" ", @class), " h-")) and @data] ' ,
11711177 );
11721178
11731179 foreach ($ xpaths as $ path ) {
11741180 $ els = $ this ->xpath ->query ($ path , $ e );
11751181
1176- if ($ els ->length == 1 ) {
1182+ if ($ els !== false && $ els ->length = == 1 ) {
11771183 $ el = $ els ->item (0 );
1178- $ hClasses = mfNamesFromElement ($ el , 'h- ' );
1179-
1180- // no nested h-
1181- if (empty ($ hClasses )) {
1182-
1183- if ($ el ->tagName == 'img ' ) {
1184- return $ el ->getAttribute ('src ' );
1185- } else if ($ el ->tagName == 'object ' && $ el ->hasAttribute ('data ' )) {
1186- return $ el ->getAttribute ('data ' );
1187- }
1188-
1189- } // no nested h-
1184+ if ($ el ->tagName == 'img ' ) {
1185+ return $ this ->resolveUrl ($ el ->getAttribute ('src ' ));
1186+ } else if ($ el ->tagName == 'object ' ) {
1187+ return $ this ->resolveUrl ($ el ->getAttribute ('data ' ));
1188+ }
11901189 }
11911190 }
11921191
0 commit comments