@@ -1078,7 +1078,7 @@ public function parseH(\DOMElement $e, $is_backcompat = false, $has_nested_mf =
1078
1078
$ photo = $ this ->parseImpliedPhoto ($ e );
1079
1079
1080
1080
if ($ photo !== false ) {
1081
- $ return ['photo ' ][] = $ this -> resolveUrl ( $ photo) ;
1081
+ $ return ['photo ' ][] = $ photo ;
1082
1082
}
1083
1083
1084
1084
}
@@ -1155,38 +1155,37 @@ public function parseH(\DOMElement $e, $is_backcompat = false, $has_nested_mf =
1155
1155
*/
1156
1156
public function parseImpliedPhoto (\DOMElement $ e ) {
1157
1157
1158
+ // img.h-x[src]
1158
1159
if ($ e ->tagName == 'img ' ) {
1159
- return $ e ->getAttribute ('src ' );
1160
+ return $ this -> resolveUrl ( $ e ->getAttribute ('src ' ) );
1160
1161
}
1161
1162
1163
+ // object.h-x[data]
1162
1164
if ($ e ->tagName == 'object ' && $ e ->hasAttribute ('data ' )) {
1163
- return $ e ->getAttribute ('data ' );
1165
+ return $ this -> resolveUrl ( $ e ->getAttribute ('data ' ) );
1164
1166
}
1165
1167
1166
1168
$ 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] ' ,
1171
1177
);
1172
1178
1173
1179
foreach ($ xpaths as $ path ) {
1174
1180
$ els = $ this ->xpath ->query ($ path , $ e );
1175
1181
1176
- if ($ els ->length == 1 ) {
1182
+ if ($ els !== false && $ els ->length = == 1 ) {
1177
1183
$ 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
+ }
1190
1189
}
1191
1190
}
1192
1191
0 commit comments