<?xml version="1.0" encoding="UTF-8"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>PHP Thumb: Forum: Showcase - Recent Posts</title>
<link>http://phpthumb.gxdlabs.com/forums/</link>
<description>Help, Suggestions, and General Discussion</description>
<language>en</language>
<pubDate>Sat, 04 Feb 2012 23:32:02 +0000</pubDate>

<item>
<title>manjushree on "show() does not show image, instead returns page url"</title>
<link>http://phpthumb.gxdlabs.com/forums/topic/show-does-not-show-image-instead-returns-page-url#post-162</link>
<pubDate>Tue, 16 Nov 2010 21:56:57 +0000</pubDate>
<dc:creator>manjushree</dc:creator>
<guid isPermaLink="false">162@http://phpthumb.gxdlabs.com/forums/</guid>
<description>&#60;p&#62;Hi&#60;/p&#62;
&#60;p&#62;I am using the following code:&#60;/p&#62;
&#60;p&#62;&#38;lt;?php&#60;br /&#62;
    require_once('simplepie1.1.3/simplepie.inc');&#60;br /&#62;
    require_once('simplepie1.1.3/idn/idna_convert.class.php');&#60;br /&#62;
    require_once('simplepie1.1.3/shorten.inc');&#60;br /&#62;
    ini_set('display_errors','On');&#60;/p&#62;
&#60;p&#62;	// sp shorten method&#60;/p&#62;
&#60;p&#62;	// Shortening function.&#60;/p&#62;
&#60;p&#62;	function shorten($string, $length)&#60;br /&#62;
	{&#60;br /&#62;
		// By default, an ellipsis will be appended to the end of the text.&#60;br /&#62;
		$suffix = '...';&#60;/p&#62;
&#60;p&#62;		// Convert 'smart' punctuation to 'dumb' punctuation, strip the HTML tags,&#60;br /&#62;
		// and convert all tabs and line-break characters to single spaces.&#60;br /&#62;
		$short_desc = trim(str_replace(array(&#34;\r&#34;,&#34;\n&#34;, &#34;\t&#34;), ' ', strip_tags($string)));&#60;/p&#62;
&#60;p&#62;		// Cut the string to the requested length, and strip any extraneous spaces&#60;br /&#62;
		// from the beginning and end.&#60;br /&#62;
		$desc = trim(substr($short_desc, 0, $length));&#60;/p&#62;
&#60;p&#62;		// Find out what the last displayed character is in the shortened string&#60;br /&#62;
		$lastchar = substr($desc, -1, 1);&#60;/p&#62;
&#60;p&#62;		// If the last character is a period, an exclamation point, or a question&#60;br /&#62;
		// mark, clear out the appended text.&#60;br /&#62;
		if ($lastchar == '.' &#124;&#124; $lastchar == '!' &#124;&#124; $lastchar == '?') $suffix='';&#60;/p&#62;
&#60;p&#62;		// Append the text.&#60;br /&#62;
		$desc .= $suffix;&#60;/p&#62;
&#60;p&#62;		// Send the new description back to the page.&#60;br /&#62;
		return $desc;&#60;br /&#62;
	}&#60;/p&#62;
&#60;p&#62;	function copyFile($img_url,$img_name)&#60;br /&#62;
							{&#60;br /&#62;
							    $crl_ptr= curl_init( $img_url );&#60;br /&#62;
							    $file_ptr=fopen($img_name,'w');&#60;/p&#62;
&#60;p&#62;							    curl_setopt( $crl_ptr, CURLOPT_FILE, $file_ptr );&#60;br /&#62;
							    curl_setopt( $crl_ptr, CURLOPT_HEADER, 0 );&#60;br /&#62;
							    curl_exec  ( $crl_ptr );&#60;/p&#62;
&#60;p&#62;							    $curl_info = curl_getInfo( $crl_ptr );&#60;br /&#62;
							    curl_close($crl_ptr );&#60;br /&#62;
							    fclose($file_ptr);    &#60;/p&#62;
&#60;p&#62;}&#60;/p&#62;
&#60;p&#62;require_once '../ThumbLib.inc.php';&#60;/p&#62;
&#60;p&#62;		// display wordpress images starts&#60;br /&#62;
		$b=''; // initialize variable to zero&#60;br /&#62;
		$feed = new SimplePie();&#60;/p&#62;
&#60;p&#62;		$feed-&#38;gt;set_feed_url(array('http://www.fakingnews.com/feed/'));&#60;/p&#62;
&#60;p&#62;		$feed-&#38;gt;enable_cache(true);&#60;br /&#62;
		$feed-&#38;gt;set_cache_duration(3600);&#60;br /&#62;
		$feed-&#38;gt;set_cache_location('cache');&#60;br /&#62;
		$feed-&#38;gt;init();&#60;br /&#62;
		$feed-&#38;gt;handle_content_type();&#60;/p&#62;
&#60;p&#62;		$i=0;$flag=0;	$fetched_url ='';&#60;/p&#62;
&#60;p&#62;		foreach ($feed-&#38;gt;get_items(0,4) as $key =&#38;gt;$item)&#60;br /&#62;
		{&#60;/p&#62;
&#60;p&#62;		$url = $item-&#38;gt;get_permalink();&#60;br /&#62;
		$posturl	=preg_replace(&#34;/(http:\/\/)/i&#34;,'',$url);  &#60;/p&#62;
&#60;p&#62;		// Match the image tags in the content&#60;br /&#62;
		preg_match_all('/&#38;lt;img([^&#38;gt;]*)&#38;gt;/i', $item-&#38;gt;get_content(), $matches);&#60;/p&#62;
&#60;p&#62;		$itemdate = $item-&#38;gt;get_date(&#34;H:i a&#34;);&#60;/p&#62;
&#60;p&#62;		// Get all of the image tags&#60;/p&#62;
&#60;p&#62;				foreach ($matches as $value)&#60;br /&#62;
				{&#60;/p&#62;
&#60;p&#62;					foreach ($value as $val)&#60;br /&#62;
					{&#60;/p&#62;
&#60;p&#62;						if (preg_match_all('/src=\&#34;([^\&#34;]+)\&#34;/i', $val,$matches))&#60;br /&#62;
						{&#60;/p&#62;
&#60;p&#62;							$b='';&#60;br /&#62;
							// $image_match = $matches[1][1];&#60;br /&#62;
							$image_url = $matches[0][0];&#60;/p&#62;
&#60;p&#62;							$a= str_replace('src=', '',$image_url);&#60;br /&#62;
														$b= str_replace('&#34;','',$a);&#60;br /&#62;
							echo &#34;&#38;lt;b&#38;gt;&#34;.$b.&#34;&#38;lt;/b&#38;gt;&#34;;&#60;/p&#62;
&#60;p&#62;/**&#60;br /&#62;
* @desc file: This source was used for copying images from another server to our own server and can be modified according to requirements.&#60;br /&#62;
*/&#60;br /&#62;
//***********************URL of image which you need**************&#60;br /&#62;
$img_url='http://roomenvy.files.wordpress.com/2010/02/living-room1.jpg';&#60;br /&#62;
$ext_arr=explode(&#34;/&#34;,$img_url);&#60;br /&#62;
$cnt=count($ext_arr);&#60;br /&#62;
//***********************name of new image you want to keep*************&#60;br /&#62;
$img_name=$ext_arr[($cnt-1)];&#60;br /&#62;
copyFile($img_url,$img_name);//Call the CURL function for getting image&#60;br /&#62;
/**&#60;br /&#62;
* @desc This function uses curl for coping a remote image file from another server to its own directory.&#60;br /&#62;
*/&#60;/p&#62;
&#60;p&#62;$img='living-room1.jpg';&#60;br /&#62;
$thumb = PhpThumbFactory::create($img);&#60;br /&#62;
// displaying images&#60;br /&#62;
$fileName = (isset($_GET['file'])) ? urldecode($_GET['file']) : null;&#60;br /&#62;
if ($fileName === null &#124;&#124; !file_exists($fileName))&#60;br /&#62;
{&#60;br /&#62;
     // handle missing images however you want... perhaps show a default image??  Up to you...&#60;br /&#62;
}&#60;br /&#62;
try&#60;br /&#62;
{&#60;br /&#62;
     $thumb = PhpThumbFactory::create($fileName);&#60;br /&#62;
}&#60;br /&#62;
catch (Exception $e)&#60;br /&#62;
{&#60;br /&#62;
     // handle error here however you'd like&#60;br /&#62;
}&#60;br /&#62;
$thumb-&#38;gt;adaptiveResize(180, 60);&#60;br /&#62;
$thumb-&#38;gt;show();&#60;/p&#62;
&#60;p&#62;							// get the image width and height&#60;br /&#62;
								list($width, $height) = getimagesize($b);&#60;br /&#62;
								 echo &#34;$width x $height (px)&#34;;&#60;br /&#62;
								 echo &#34;&#60;br /&#62;&#34;;&#60;br /&#62;
								// get the image width and height ends&#60;/p&#62;
&#60;p&#62;}}}}&#60;br /&#62;
?&#38;gt;&#60;/p&#62;
&#60;p&#62;It creates thumb and saves also properly. But when the show method is added it does not show the images. If I create a page and add the saving, creating thumb and showing the thumb methods in a page, it works perfectly. But the moment I add this code inside the simplepie parser code, it creates a problem. Please if anyone can help me ou with this problem.&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Manjushree &#60;/p&#62;
&#60;p&#62;&#38;lt;/body&#38;gt;&#60;br /&#62;
&#38;lt;/html&#38;gt;
&#60;/p&#62;</description>
</item>

</channel>
</rss>

