babyewok Posted March 29, 2018 Share Posted March 29, 2018 OK So I am using the rss feed block to show the three latest items from a wordpress blog that is on the same domain as the prestashop store (I have to use feedburner to do this as by default the blog can't be on the same domain for some weird reason). Anyway, after much faffing I was able to show the featured image for each post on the feed. However, randomly the 3rd image doesn't load. For that image, the source code on the page reads: <img src(unknown) ..... Even though this image was working fine when it was the 1st or 2nd post, sometimes when it gets demoted to 3rd place, the image just isn't showing, even though it is present in the rss feed! The feed is structured like this: <TITLE>Post title</TITLE> <LINK>http://website.com/blog/2018/02/post/</LINK> <PUBDATE>Mon, 15 Feb 2018 08:39:00 +0000</PUBDATE> <DC:CREATOR><![CDATA[Kitty & Dulcie]]></DC:CREATOR> <CATEGORY><![CDATA[Uncategorised]]></CATEGORY> <CATEGORY><![CDATA[sale]]></CATEGORY> <GUID isPermaLink="false"></GUID> <DESCRIPTION><![CDATA[<div><img width="283" height="185" src="http://website.com/blog/wp-content/uploads/2018/03/image-283x185.jpeg" class="attachment-my-rss-thumb size-my-rss-thumb wp-post-image" alt="Blah blah" srcset="http://website.com/blog/wp-content/uploads/2018/03/image-283x185.jpeg 283w, http://website.com/blog/wp-content/uploads/2018/03/image-665x435.jpeg 665w" sizes="(max-width: 283px) 100vw, 283px" /></div> Blah Blah blah […]]]></DESCRIPTION> </ITEM> and blockrss.php reads at line 150: // First image if (isset($xmlValues['content']) && $xmlValues['content']) { preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/', $xmlValues['content'], $image); if (array_key_exists(1, $image) && $image[1]) { if ($image[1][0] == '/') $image[1] = 'http:'.$image[1]; // Try if distant image exist : timeout 0.3s $context = stream_context_create(array('http' => array('timeout' => 0.3))); if (file_get_contents($image[1], false, $context, -1, 1) !== false) $xmlValues['image'] = $image[1]; } $text = $xmlValues['content']; $xmlValues['text'] = preg_replace("/<img[^>]+\>/i", "", $text); } You can see I added 'text' to strip out the image from the content. I tried all sorts and the only way I could pull the image was to put it in the content! The template looks like this: <div id="rss_block"> <h2>{$title}</h2> <div class="block_content"> {if $rss_links} <ul>{foreach from=$rss_links item='rss_link'} <li><div class="blog-img"><a href="{$rss_link.url}"><img src="{$rss_link.image}" alt="{$rss_link.title}" /></a></div> <h3><a href="{$rss_link.url}">{$rss_link.title}</a></h3> <p>{$rss_link.text|truncate:195}</p> <a href="{$rss_link.url}" class="more-blog">Continue Reading ></a></li> {/foreach} </ul> {else} <p>{l s='No RSS feed added' mod='blockrss'}</p> {/if} </div> </div> Sometimes, that 3rd image loads, other times it doesn't, even after clearing the cache and refreshing the page. I really don't get what is going on! Does anyone have any suggestions? Link to comment Share on other sites More sharing options...
babyewok Posted April 3, 2018 Author Share Posted April 3, 2018 No one? Link to comment Share on other sites More sharing options...
ukbaz Posted March 19, 2019 Share Posted March 19, 2019 Did you ever get this sorted - I have a similar issue! thanks Baz Link to comment Share on other sites More sharing options...
mafiuz Posted August 15, 2019 Share Posted August 15, 2019 (edited) I have the same problem... any ideas what is the issue? Edited August 15, 2019 by mafiuz (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now