coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 cpmFetch by vuud => Topic started by: gammann on December 28, 2008, 11:51:54 PM

Title: cpmfetch rss feed for kodak digital picture frame
Post by: gammann on December 28, 2008, 11:51:54 PM
Since I didn't see anything else here about creating a feed for digital picture frames, I thought I'd share how I got mine to work.  The Kodak W1020 frame wanted the <media:content> tag in order to display the picture.  Here is how to add the tag to the rss_lastadded.php feed.

I used the v1.8.0-dev version of feedcreator.class.php.  This version changes the encoding from ISO-8859-1 to utf-8.  It also adds a GUID tag by default.  I'm not sure if these make a difference for the frame, but I tried quite a few things, so once I got it working, I left it alone.

Edit feedcreator.class.php, class RSSCreator091, function createFeed(), change:
$feed.= "<rss version=\"".$this->RSSVersion."\">\n";
to

$feed.= "<rss version=\"".$this->RSSVersion."\"";
if ( isset ($this->media) ){
      $feed.= " xmlns:media=\"http://search.yahoo.com/mrss/\"";
}
$feed.= ">\n";

I got this bit of code from http://www.bitweaver.org/cvs-repo/_bit_rss/feedcreator.class.php?revision=1.10&view=markup (http://www.bitweaver.org/cvs-repo/_bit_rss/feedcreator.class.php?revision=1.10&view=markup)

Edit feedcreator.class.php, class RSSCreator091, function createFeed() :
after:
$feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, "        ");

Add:

if ( $this->items[$i]->media_content!=""){
$feed.= "        <media:content url='".$this->items[$i]->media_content."'/>\n";
}


Edit cfrssget.php, function generateFeedFromResults:
Before this line:
$this->rss->addItem($item);
Add:

$item->media = '';
$item->media_content=''.$this->cpm->cpm_getConfigEntry('cpg_url').$this->cpm->urlEncodeImagePath($this->cpm->getImageToUse($data['pFilepath'],$data['pFilename'], $this->cpm->cfg['_pfx'])) .'';


If anyone knows a better way to do this, please let me know.  I'd like to be able to add the picture desctription at the bottom of the photo, but since the frame seems to ignore every other tag, except the media:content tag, I assume I'd have to generate the picture on the fly, adding the description text to the photo.

Jerry
Title: Re: cpmfetch rss feed for kodak digital picture frame
Post by: vuud on December 29, 2008, 03:49:59 AM
This is fantastic!
Title: Re: cpmfetch rss feed for kodak digital picture frame
Post by: gammann on January 11, 2009, 06:56:18 AM
I also wanted the weather mixed in with my photos so I hacked up some code to do so.  Basically this uses weatherforyou.com (http://weatherforyou.com) to supply the images of the weather.  It saves the images to the tmp directory everytime the rss page is called, since the frame would not go out and grab the image from weatherforyou.com on the fly.

In rss_latestadd.php, after:
include "cfrssget_new.php";
Add:

$zip = $_GET['zipcode'];
if ($zip != null)
{
$weather = "http://www.weatherforyou.net/fcgi-bin/hw3/hw3.cgi?config=jpg&forecast=zandh&alt=hwizandh&zipcode=".$zip."&country=us&daysonly=2&maxdays=5";
$tmp_weather_file = ".\\tmp\\".$zip.".jpg";
file_put_contents($tmp_weather_file, file_get_contents($weather));
$weather_img = "cpmfetch/tmp/".$zip.".jpg";
}


In cfrssget.php, class cfrss, add the following function at the end:

function addWeather ($weather_url)
{

$item = new FeedItem();
$titleToUse = "Weather";
$descriptionToUse="";
$item->title = $titleToUse;

$item->link =''.$this->cpm->cpm_getConfigEntry('cpg_url').$weather_url;
$item->media = '';
$item->media_content =''.$this->cpm->cpm_getConfigEntry('cpg_url').$weather_url .'';
$imagetag = '<img src="'.$this->cpm->cpm_getConfigEntry('cpg_url').$weather_url.'" />';
$descriptionToUse = $imagetag . $descriptionToUse.' ';
$item->description = $descriptionToUse;

$item->date = date(DATE_RFC822);

$this->rss->addItem($item);
}


Now when you setup the feed in the frame, add the zipcode variable to the url like:
http://www.mysite.com/cpm/cpmfetch/rss_latestadded.php?zipcode=20500
Title: Re: cpmfetch rss feed for kodak digital picture frame
Post by: gammann on January 11, 2009, 07:07:24 AM
forgot to add the following:

in rss_latestadded.php, before the following line:
$cfrss->endFeed();

Add:

if ($zip != null)
{
$cfrss->addWeather($weather_img);
}