Image Feed Widget
Random Images on Image Feed Widget (2 posts)

  1. themoosemethod
    Posted 4 years ago #

    Does anyone know how to set the images to display in a random order? It seems like it pulls them in order..


  2. Daiv Mowbray
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Image Feed Widget
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic