FeedForAll Forum Index  
 Home  •  FAQ  •   Search   •  Register   •  Profile   •  Log in
 Example: 4 - Get the image embedded in the description View next topic
View previous topic
Post new topicReply to topic
Author Message
randeh



Joined: 16 Sep 2015
Posts: 8
Location: Florida

PostPosted: Wed Sep 16, 2015 12:21 pm Reply with quoteBack to top

I am trying to use Example: 4 - Get the image embedded in the description from the rss2html-pro-examples.txt file. It does not seem to be finding my image in the description. The only thing it is doing is placing "$theImage" to the left of the image. Here is the url to the site I am testing the pro version with different feeds. [url]http://productreviews.mobi/rss/outputimage2.php[/url]

The only thing that look odd to me was this line although I know very little php. $theImage = ' ';

Can you please point me in the right direction.

Thank you,

Randy



[code]<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>~~~FeedTitle~~~</title>
</head>
<body>
<h1>~~~FeedTitle~~~</h1>
<p>~~~FeedDescription~~~</p>
<hr>
<table width="100%">
~~~BeginItemsRecord~~~
<?php
// Set initial values for our variables
$theImage = '&nbsp;';
// To ensure proper display with borders
$newDescription = '~~~ItemDescription~~~';
$match = Array();

// Use regular expressions to find <img ... >
if (preg_match('/<img[^>]*>/', $newDescription, $match) !== FALSE) {
// Make sure it truely was a match
if ((count($match) != 0) && ($match[0] != '')) {
// Save the image
$theImage = $match[0];
// Remove the image from the description
$newDescription = str_replace($match[0], '', $newDescription);
}
}

echo '<tr><td>$theImage</td><td>~~~ItemPubShortDate~~~ ~~~ItemPubShortTime~~~<br />';
echo '~~~ItemTitle~~~<br />';
echo $newDescription.'</td></tr>';
echo '<tr><td colspan="2"><hr></td></tr>';
?>
~~~EndItemsRecord~~~
</table>
</body>
</html>[/code][/url]
View user's profile
Tech Support



Joined: 27 Aug 2004
Posts: 2783

PostPosted: Wed Sep 16, 2015 3:26 pm Reply with quoteBack to top

Try replacing the single quotes in the following line with double quotes.

Change
Code:
echo '<tr><td>$theImage</td><td>~~~ItemPubShortDate~~~ ~~~ItemPubShortTime~~~<br />';


to

Code:
echo "<tr><td>$theImage</td><td>~~~ItemPubShortDate~~~ ~~~ItemPubShortTime~~~<br />";

_________________
Create RSS Feeds
Audio Recording and Editing
View user's profile
randeh



Joined: 16 Sep 2015
Posts: 8
Location: Florida

PostPosted: Wed Sep 16, 2015 4:26 pm Reply with quoteBack to top

That takes care of removing the $theimage tag although the code is not giving me a separate image from the description.

I removed the [code]echo $newDescription.'</td></tr>';[/code] line and the image went away; of coarse along with the description.

I want to be able to have the image separate so that I can place it above my Item Title. It seems that the image is not being pulled from the description.

Is this variable correct [code]$theImage = '&nbsp;';[/code]

Thank you for your help I appreciate it very much.

Kind regards,

Randy
View user's profile
Tech Support



Joined: 27 Aug 2004
Posts: 2783

PostPosted: Thu Sep 17, 2015 10:03 am Reply with quoteBack to top

That is odd.

Try changing

Code:
if (preg_match('/<img[^>]*>/', $newDescription, $match) !== FALSE) {


to

Code:
if (preg_match('/<img[^>]*>/', $newDescription, $match) == 1) {

_________________
Create RSS Feeds
Audio Recording and Editing
View user's profile
randeh



Joined: 16 Sep 2015
Posts: 8
Location: Florida

PostPosted: Thu Sep 17, 2015 10:32 am Reply with quoteBack to top

No that did not work. I even tried removing the double quotes from yesterday's change. The image is still within the description tag.

Here is the first item from the source, I see the [code]<img src="http://ecx.images-amazon.com/images/I/415mz9uYreL._SL160_.jpg[/code] within the description tag.

[code]<title>#1: Citric Acid - 1lb - Made in USA - 100% Pure for Food Use - Organic Certified and No Anti-caking Agents. 90 Day Satisfaction Guarantee.</title> <guid isPermaLink="false">top-rated_industrial_industrial_B00XI3OLW4</guid> <link> http://www.amazon.com/Citric-Acid-Anti-caking-Satisfaction-Guarantee/dp/B00XI3OLW4/ref=pd_zg_rss_tr_indust_industrial_1 </link> <pubDate>Thu, 17 Sep 2015 15:19:27 GMT</pubDate> <description><![CDATA[<div style="float:left;"><a class="url" href="http://www.amazon.com/Citric-Acid-Anti-caking-Satisfaction-Guarantee/dp/B00XI3OLW4/ref=pd_zg_rss_tr_indust_industrial_1"><img src="http://ecx.images-amazon.com/images/I/415mz9uYreL._SL160_.jpg" alt="Citric Acid" border="0" hspace="0" vspace="0" /></a></div><span class="riRssTitle"><a href="http://www.amazon.com/Citric-Acid-Anti-caking-Satisfaction-Guarantee/dp/B00XI3OLW4/ref=pd_zg_rss_tr_indust_industrial_1">Citric Acid - 1lb - Made in USA - 100% Pure for Food Use - Organic Certified and No Anti-caking Agents. 90 Day Satisfaction Guarantee.</a></span> <br /><span class="riRssContributor">Halechem</span> <br /> <img src="http://g-ecx.images-amazon.com/images/G/01/detail/stars-5-0._V192261437_.gif" width="64" alt="4.9 out of 5 stars" align="absbottom" height="12" border="0" style="margin: 0; padding: 0;"/>(437)<br /><br /><a href="http://www.amazon.com/Citric-Acid-Anti-caking-Satisfaction-Guarantee/dp/B00XI3OLW4/ref=pd_zg_rss_tr_indust_industrial_1">Buy new: </a> <strike>$11.99</strike> <font color="#990000"><b>$8.97</b></font> <br /><br />(Visit the <a href="http://www.amazon.com/gp/top-rated/industrial/ref=pd_zg_rss_tr_indust_industrial_1">Top Rated in Industrial & Scientific</a> list for authoritative information on this product's current rank.)]]></description> </item>[/code]

Thank you for your help.

Randy
View user's profile
Tech Support



Joined: 27 Aug 2004
Posts: 2783

PostPosted: Fri Sep 18, 2015 5:28 am Reply with quoteBack to top

I want to try to reproduce your problem here.

If all the rss2html stuff is in its own folder, can you zip up that folder and send it to support@notepage.com? If not in its own folder, just zip up all the rss2html files and send them along.

Thanks

_________________
Create RSS Feeds
Audio Recording and Editing
View user's profile
randeh



Joined: 16 Sep 2015
Posts: 8
Location: Florida

PostPosted: Fri Sep 18, 2015 11:38 am Reply with quoteBack to top

Just to follow up and make sure you received my email with attached files. Sent today at 10:13 am EST.

Thank you,

Randy
View user's profile
Display posts from previous:      
Post new topicReply to topic


 Jump to:   



View next topic
View previous topic


Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme