1

I’ve a Wordpress site where I uses my Flickr feed to get my latest images. By using a script, I create a new post everytime I’ve a new image on Flickr but, the image thumbnail source is from Flickr and when I press the thumbnail I’m redirected to the Flickr image.

I want to close down my wordpress site for any new content and want to close it off from all third part APIs and Services, so I want to run through my list of Flickr posts and download every thumbnails and images I’m referring to.

An example of a Flickr post on my blog with an image looks like this:

<a href="http://www.flickr.com/photos/2332432@N06/554435234/">
<img alt="My ALT text" src="http://farm8.staticflickr.com/2213/35554564_5fhe10fj22_m.jpg"
</a>

If it can be done I would like to download both the thumbnail and the large picture but otherwise an acceptable solution would be just to download the thumbnail image (the image from farm8.staticflickr.com).

I’ve tried different approached but none have worked. One I tried was this (which I’m using to extract the Vimeo thumbnail, so therefor I thought I would work on the Flickr Thumbnail):

$ch = curl_init($the-image-url-variable);
$fp = fopen('$thename.jpg', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);

When I’m using this code, it does indeed generate an image in my folder but the image is invalid and can’t show any content..

Any help or suggestions would be appreciated.

Sincere
- Mestika

Emil Devantie Brockdorff
  • 4,724
  • 12
  • 59
  • 76
  • 1
    `fopen('$thename.jpg', 'wb')` - Don't you mean to use double quotes to parse the variable? Otherwise it's opening a file literally named `$thename.jpg`. Not sure if that would cause your problem though. If [`allow_url_fopen`](http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen) is enabled, have you tried simply using [`file_get_contents($url)`](http://php.net/file_get_contents) instead of using cURL? – Wiseguy Jan 25 '12 at 17:25
  • You should use `fopen("$thename.jpg", 'wb');` otherwise you look for an image literally named '$thename.jpg'. – entropid Jan 25 '12 at 17:51

0 Answers0