@@ -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 ' ) {
11591160 return $ e ->getAttribute ('src ' );
11601161 }
11611162
1163+ // object.h-x[data]
11621164 if ($ e ->tagName == 'object ' && $ e ->hasAttribute ('data ' )) {
11631165 return $ e ->getAttribute ('data ' );
11641166 }
11651167
11661168 $ xpaths = array (
1167- './img ' ,
1168- './object ' ,
1169- './*[count(preceding-sibling::*)+count(following-sibling::*)=0][not(contains(concat(" ", @class), " h-"))]/img[count(preceding-sibling::img)+count(following-sibling::img)=0] ' ,
1170- './*[count(preceding-sibling::*)+count(following-sibling::*)=0][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] ' ,
1171+ // .h-x>object[data]:only-of-type:not[.h-*]
1172+ './object[not(contains(concat(" ", @class), " h-")) and count(../object) = 1] ' ,
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-"))] ' ,
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-"))] ' ,
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 $ el ->getAttribute ('src ' );
1186+ } else if ($ el ->tagName == 'object ' && $ el ->hasAttribute ('data ' )) {
1187+ return $ el ->getAttribute ('data ' );
1188+ }
11901189 }
11911190 }
11921191
0 commit comments