This isn’t rocket science, but I did search Google extensively before building my own script. Save the script as Random_Flickr_Image.php (or whatever) and reference it in your img tag. For example, <img src=”/images/Random_Flickr_Image.php”/>.
Edit: I’ve updated the script to it works again. Flickr must have updated the image element class from photoImgDiv to photo-div.
<?php
$doc = new DOMDocument();
@$doc->loadHTMLFile("http://www.flickr.com/explore/interesting/7days/");
$xpath = new DOMXpath($doc);
if($xpath){
$url = $xpath->query("//td[@class='Photo']/span/a/@href");
@$doc->loadHTMLFile("http://www.flickr.com".$url->item(0)->nodeValue);
$xpath = new DOMXpath($doc);
if($xpath){
$url = $xpath->query("//div[@class='photo-div']/img/@src");
$im = @imagecreatefromjpeg($url->item(0)->nodeValue);
if($im){
header('content-type: image/jpeg');
imagejpeg($im);
}else
echo "error";
}
}
?>










Pingback: Random Flickr Image Slider Puzzle Using Canvas Tags | PlanetB
Pingback: Johan Ronström » Blog Archive » Image game