SimplePortal

Support => English Support => Topic started by: Aw06 on February 06, 2009, 03:17:15 AM

Title: RSS Images
Post by: Aw06 on February 06, 2009, 03:17:15 AM
How can i snip out or rezize any image that gets pulled in an RSS feed... ??
Title: Re: RSS Images
Post by: [SiNaN] on February 06, 2009, 03:22:45 AM
Snip out? You mean remove?
Title: Re: RSS Images
Post by: Aw06 on February 06, 2009, 03:25:25 AM
Snip out? You mean remove?

well by snip i mean ... remove the image but leaves a link to the image ...

eg.
(http://simpleportal.net/index.php?action=dlattach;attach=660;type=avatar)

<image snipped (http://simpleportal.net/index.php?action=dlattach;attach=660;type=avatar)>

Reason i want this .. some times it pulls in a really larggeee image .. and messes up the layout of the site
Title: Re: RSS Images
Post by: Nathaniel on March 31, 2009, 07:29:54 AM
You should be able to do this with the PHP preg_replace() function and a decent regular expression. Not sure if you know much about those though.

Would you like me to try and write one?
Title: Re: RSS Images
Post by: Killer-B on April 02, 2009, 07:29:21 PM
I now have the REVERSE problem -

On my main RSS Feed (Portal Page) my 1st post under the old portal would show the RSS TEXT as well as a thumbnail image that came with the feed - now it's Text Only?

Also, the Block Size for RSS - it has gotten smaller and now use "sidebars" - anyway to go back and adjust the block size to show more feeds? and get my photos back (I see there's a new icon set too)


Otherwise - looks nice   www.f-1chat.com
Title: Re: RSS Images
Post by: [SiNaN] on April 03, 2009, 03:46:21 AM
2.2 still has the Custom PHP block, so you can still use the old block codes in a PHP Block.

Code: [Select]
global $rss_data, $rss_current, $rss_counter;

$parameters[0] = 'http://www.formula1.com/rss/news/latest.rss';

if (empty($parameters[0]))
return;
else
$feed = $parameters[0];

$rss_data = array();
$rss_current = "";
$rss_counter = 0;
$rss_main = '';

$xml_parser = xml_parser_create();

xml_set_element_handler($xml_parser, "sp_startElement", "sp_endElement");

xml_set_character_data_handler($xml_parser, "sp_characterData");

if (!($fp = @fopen($feed, "r")))
return;

while ($data = fread($fp, 4096))
{
if (!xml_parse($xml_parser, $data, feof($fp)))
{
$xmlerr = (sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)), 
xml_get_current_line_number($xml_parser)));

break;
}
}

fclose($fp);

xml_parser_free($xml_parser);

if (!empty($xmlerr))
{
echo $xmlerr;

return;
}

if (empty($rss_data))
return;

if (!empty($rss_data['IMAGE']))
echo '<a href="', $rss_data['LINK'], '" target="_blank"><img src="', $rss_data['IMAGE']['URL'], '" align="middle" alt="', $rss_data['IMAGE']['TITLE'], '" /></a>', $rss_data['TITLE'], '<br /><br />';
else
echo $rss_data['TITLE'], '<br />';

echo '<em>', $rss_data['DESCRIPTION'], '</em><br />';

if (isset($rss_data['ITEMS']))
{
if (count($rss_data['ITEMS']) > 0)
{
for($i = 0; $i < count($rss_data['ITEMS']); $i++)
{
echo '<span style="font-weight: bold;"><a href="', $rss_data['ITEMS'][$i]['LINK'], '" target="_blank">', $rss_data['ITEMS'][$i]['TITLE'], '</a></span><br />';
echo html_entity_decode($rss_data['ITEMS'][$i]['DESCRIPTION']) . '<br />';
if ($i != count($rss_data['ITEMS']) - 1)
echo '<hr />';
}
}
else
return;
}
Title: Re: RSS Images
Post by: Killer-B on April 03, 2009, 01:18:26 PM
Thanks for the response SiNan...

I'm using a HTML block - and not very good with PHP -

But the "code" you posted above, is that php code to be used in a php box instead of a HTML block? (sorry for stupid Q - I just want to be clear)...

I will try it... and hope it brings back my RSS pix - that was a great feature!

Thanks for the help!

KB
Title: Re: RSS Images
Post by: Killer-B on April 03, 2009, 01:22:15 PM
WORKED PERFECT!! Yeah!!!!!  8)

Thank you!!!

www.f-1chat.com
Title: Re: RSS Images
Post by: Nathaniel on April 03, 2009, 08:32:34 PM
Aw06,
Did Sinan's code solve this issue for you as well?
Title: Re: RSS Images
Post by: Aw06 on April 08, 2009, 10:33:48 AM
Aw06,
Did Sinan's code solve this issue for you as well?

i no longer use rss blocks
Title: Re: RSS Images
Post by: Eliana Tamerin on April 08, 2009, 12:16:18 PM
Topic marked solved, then.
SimplePortal 2.3.8 © 2008-2024, SimplePortal