Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I spent ages searching for a way of displaying images in RSS via Magpie myself, and in the end I had to examine the code to figure out how to get it to work.</p> <p>Like you say, the reason Magpie doesn't pick up images in the element is because they are specified using the 'enclosure' tag, which is an empty tag where the information is in the attributes, e.g.</p> <pre><code>&lt;enclosure url="http://www.mysite.com/myphoto.jpg" length="14478" type="image/jpeg" /&gt; </code></pre> <p>As a hack to get it to work quickly for me I added the following lines of code into rss_parse.inc:</p> <pre><code> function feed_start_element($p, $element, &amp;$attrs) { ... if ( $el == 'channel' ) { $this-&gt;inchannel = true; } ... // START EDIT - add this elseif condition to the if ($el=xxx) statement. // Checks if element is enclosure tag, and if so store the attribute values elseif ($el == 'enclosure' ) { if ( isset($attrs['url']) ) { $this-&gt;current_item['enclosure_url'] = $attrs['url']; $this-&gt;current_item['enclosure_type'] = $attrs['type']; $this-&gt;current_item['enclosure_length'] = $attrs['length']; } } // END EDIT ... } </code></pre> <p>The url to the image is in $myRSSitem['enclosure_url'] and the size is in $myRSSitem['enclosure_length']. Note that enclosure tags can refer to many types of media, so first check if the type is actually an image by checking $myRSSitem['enclosure_type'].</p> <p>Maybe someone else has a better suggestion and I'm sure this could be done more elegantly to pick up attributes from other empty tags, but I needed a v quick fix (deadline pressures) but I hope this might help someone else in difficulty!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload