File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 3
3
* Plugin for http://postimage.org
4
4
*
5
5
* @release Jun 19, 2014
6
- * @lastupdate Jan 20 , 2015
6
+ * @lastupdate Mar 207 , 2015
7
7
*/
8
8
class ChipVN_ImageUploader_Plugins_Postimage extends ChipVN_ImageUploader_Plugins_Abstract
9
9
{
@@ -164,9 +164,7 @@ protected function getGeneralParameters()
164
164
*/
165
165
private function getImageFromResult ($ url )
166
166
{
167
- $ imageId = $ this ->getMatch ('#^http://post(?:img|image)\.org/\w+/([^/]+)/.*?# ' , $ url );
168
-
169
- if (! $ imageId ) {
167
+ if (!$ this ->getMatch ('#^http://post(?:img|image)\.org/\w+/([^/]+)/.*?# ' , $ url )) {
170
168
$ this ->throwException ('%s: Image ID not found. ' , __METHOD__ );
171
169
}
172
170
@@ -176,10 +174,19 @@ private function getImageFromResult($url)
176
174
177
175
$ imageUrl = $ this ->getMatch ('#id="code_2".*?>(https?://\w+\.postimg\.org/\w+/\w+\.\w+)#i ' , $ this ->client );
178
176
177
+ if (!$ imageUrl
178
+ && $ url = $ this ->getMatch ('#id="code_1".*?>(http.*?)<#i ' , $ this ->client )
179
+ ) {
180
+ // try to fetch direct link from image page
181
+ $ this ->resetHttpClient ()
182
+ ->setUserAgent ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.76 Safari/537.36 ' )
183
+ ->execute ($ url );
184
+
185
+ $ imageUrl = $ this ->getMatch ('#rel="image_src".*?href="([^"]+)"#i ' , $ this ->client );
186
+ }
179
187
if (!$ imageUrl ) {
180
188
$ this ->throwException ('%s: Image URL not found. ' , __METHOD__ );
181
189
}
182
-
183
190
return $ imageUrl ;
184
191
}
185
192
}
You can’t perform that action at this time.
0 commit comments