<?php
/**
* WiseLoop PHP Web Media Grabber Sample<br/>
* Title: Flickr<br/>Gallery (adv.)
*/
$demoHandler = new wlDemo('php-web-media-grabber');
$basePath = $demoHandler->getPackageUrl();
require_once dirname(__FILE__) . "/../php-web-media-grabber/bin/wlWmg.php"; //including the WiseLoop PHP Web Media Grabber Package
require_once dirname(__FILE__) . "/../php-graphic-works/bin/wlGw.php"; //including the WiseLoop PHP Graphic Works Package
$url = 'http://www.flickr.com/search/?q=school&f=hp'; //the url
$ig = new wlWmgImageGrabber($url, array('.jpg', '.jpeg')); //creating the filtered(by .jpg and .jpeg extensions) image grabber object
$ig->setGrabOnlyFromTagSlice('photo-display-container'); //limiting the searching area: only images founded inside that tag will be grabbed
$ig->setLimit(10); //limiting the grabbed images count: only first 10 images will be grabbed
$ig->setFollowSubpagesLinks(true); //activating the sub-pages links following
$ig->setFollowedSubpageGrabOnlyFromTagSlice('main-photo-container');//limiting the sub-page searching area for finding the full size images
$ig->setDoDownload(true); //enabling the download feature
$ig->grab(); //the grab command
/**
* @var wlWmgMedia $thumb
* @var wlWmgMedia $image
*/
$thumbs = $ig->getMediaRoots(); //get the images thumbs (media that have kids)
foreach ($thumbs as $thumb) {
$images = $ig->getMediaKids($thumb); //get the thumb full size images (only one in this case)
if (count($images)) {
$image = $images[0]; //get the thumb full size image
$fxChain = 'CropAlign(center-center, 100, 70);Mask(rounded, 10);Reflection();'; //the effects chain to be applied over the thumbs
$fxThumbPath = $basePath . '/../php-graphic-works/live/do.php?img=' . $thumb->getGrabbedUrl() . '&fx=' . $fxChain; //path to the inline graphic processor (requires WiseLoop PHP Graphic Works)
echo '<a target="_blank" href="' . $image->getGrabbedUrl() . '" style="float:left; margin:10px; background-color:#ffffff; padding:5px;">';
echo '<img src="' . $fxThumbPath . '"/>';
echo '</a>';
}
}
?>