Does anyone know of a code snippet somewhere that does this? Looking to do something similar to this, but for a few images: Dynamically Generating Webpages – Insert Video | The Quiet Affiliate
I have some partial code I tried hacking up from a plugin, but can't get it to work in a wordpress page template.
I have some partial code I tried hacking up from a plugin, but can't get it to work in a wordpress page template.
Code:
<?php
if (strlen($thetag)>1){
$SafeQuery = str_replace(" ","+",$thetag);
$SafeQuery = str_replace("-","+",$SafeQuery);
$SafeQuery = strtolower($SafeQuery);
$thelink="http://api.search.live.net/xml.aspx?Appid=$bingpicturesappid&query=$SafeQuery&sources=image";
// read feed into SimpleXML object
$resp= @simplexml_load_file($thelink);
$width=getwidthkw2w($bingpicturescolumns);
$children = $resp->children('http://schemas.microsoft.com/LiveSearch/2008/04/XML/multimedia');
if ($resp){
$columncounter=1;
$i=0;
foreach ($children->Image->Results->ImageResult as $d) {
$bingurl =(string)$d->Url;
$bingimageurl= (string)$d->Thumbnail->Url;
if($i==0){$modulecontainer.="<div class=\"moduletitle\"></div>";}
$modulecontainer.="<div class=\"bingpicturesmodule\" style=\"margin-bottom:10px;float:left;width:$width;margin-right:1%;\">";
$modulecontainer.="<img class=\"bingimg\" style=\"width:$bingpictureswidth"."px;height:$bingpicturesheight"."px;\" src=\"$bingimageurl\" alt=\"\" /><br />";
$modulecontainer.="<div style=\"clear:both\"></div></div>";
if ($bingpicturescolumns==$columncounter){
$modulecontainer.="<div style=\"clear:both\"></div>\n";
$columncounter=0;
}
if (($bingpicturestotalresults-1)==$i){break;}
$columncounter++;
$i++;
}
$modulecontainer.="<div style=\"clear:both\"></div>\n";
}
}