function _emimage_imageshack_scrape_image_url in Embedded Media Field 6.3
Same name and namespace in other branches
- 6 contrib/emimage/providers/imageshack.inc \_emimage_imageshack_scrape_image_url()
Scrape the actual image URL from the ImageShack page.
Parameters
String $url: ImageShack page.
boolean $reset: If TRUE, then reset the cache.
Return value
String ImageShack image URL.
1 call to _emimage_imageshack_scrape_image_url()
- emimage_imageshack_data in contrib/
emimage/ providers/ imageshack.inc
File
- contrib/
emimage/ providers/ imageshack.inc, line 125 - This include processes imageshack.com image files for use by emfield.module.
Code
function _emimage_imageshack_scrape_image_url($url, $reset = FALSE) {
static $urls;
if (!isset($urls) || $reset) {
$urls = array();
}
if (isset($urls[$url])) {
return $urls[$url];
}
if (!$reset && ($cache = cache_get('emimage:imageshack:' . $url))) {
$urls[$url] = $cache->data;
return $urls[$url];
}
$request = drupal_http_request($url);
if ($html = $request->data) {
if (preg_match('!<img id="thepic" .+? src="(.+?)"!is', $html, $matches)) {
cache_set('emimage:imageshack:' . $url, $urls[$url] = $matches[1]);
return $urls[$url];
}
}
}