File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,6 @@ public function __construct(Request $request)
105
105
}
106
106
}
107
107
108
- //img tags
109
108
//Search the main element:
110
109
$ content = $ html ->getElementsByTagName ('main ' ); //<main> element
111
110
@@ -137,10 +136,30 @@ public function __construct(Request $request)
137
136
$ src = new Url ($ img ->getAttribute ('src ' ));
138
137
139
138
//Check whether the image is in the same domain
139
+ if ($ src ->getDomain () && $ src ->getDomain () !== $ domain ) {
140
+ continue ;
141
+ }
142
+
143
+ //Check whether the image is inside an external link
144
+ $ parent = $ img ->parentNode ;
145
+
146
+ while ($ parent && isset ($ parent ->tagName )) {
147
+ if ($ parent ->tagName === 'a ' ) {
148
+ if ($ parent ->hasAttribute ('href ' )) {
149
+ $ href = new Url ($ parent ->getAttribute ('href ' ));
150
+
151
+ if ($ href ->getDomain () && $ src ->getDomain () !== $ domain ) {
152
+ continue 2 ;
153
+ }
154
+ }
155
+
156
+ break ;
157
+ }
140
158
141
- if (!$ src ->getDomain () || $ src ->getDomain () === $ domain ) {
142
- $ images [] = $ src ->getUrl ();
159
+ $ parent = $ parent ->parentNode ;
143
160
}
161
+
162
+ $ images [] = $ src ->getUrl ();
144
163
}
145
164
}
146
165
You can’t perform that action at this time.
0 commit comments