Support » Plugin: Image Feed Widget » Random Images on Image Feed Widget

Viewing 1 replies (of 1 total)
  • I wanted the same functionality with this plugin.
    To pull just one image from the feed, but randomly select which to display, so I’ve made an adjustment to the plugin.
    At like 36 as the script goes to call for the feeds I replaced what was there with the following:

    // Get a SimplePie feed object from the specified feed source
                    $feedsarray = split(',',$feedslist);
                    $rss = fetch_feed($feedsarray);
                    // Figure out how many total items there are.
                    $maxitems = $rss->get_item_quantity((int)$maxfeeds);
                    // Build an array of all the items, starting with element 0 (first element).
                    // I have set the max number to get as 10
                    $rss_items = $rss->get_items(0,10);
                    shuffle($rss_items);// shake up the array
                    reset($rss_items); // reset index
                    // now from that 10 items, slice the array down to the maxitems
                    if( (count($rss_items) > $maxitems))$rss_items = array_slice($rss_items, 0, $maxitems);

    Works for me.

Viewing 1 replies (of 1 total)
  • The topic ‘Random Images on Image Feed Widget’ is closed to new replies.