Support » Plugin: WordPress File Upload » Display random files from WordPress File Upload directory

  • Hello!
    I’m developing a website that works like a media archive. The idea is to display a file upload interface to the users, so that anyone can submit files to the website media library.
    My client also wants me to develop a page where the users can click a button and view random content pulled from the website library. The content (mostly images and URLs) should be tagged and displayed in a frame within the page. This is where I’m stuck.
    Is there any way to pull random content (submited by the users through WordPress File Upload plugin) from the media library and display it in a page?

    Thanks in advance,

Viewing 1 replies (of 1 total)
  • Plugin Author nickboss


    Hi, it can be done with a plugin hook, like the one below:

    if (!function_exists('wfu_get_filtered_recs_alt')) {
    	function wfu_get_filtered_recs_alt($res, $filter) {
    		$num = 3;
    		$random = array();
    		$indlist = array();
    		$recs = count($res["output"]);
    		for ( $i = 0; $i < $num; $i++ ) {
    			$ind = rand(0, $recs - 1);
    			if ( !in_array($ind, $indlist) ) {
    				array_push( $indlist, $ind );
    				array_push( $random, $res["output"][$ind] );
    		$res["output"] = $random;
    		return $res;
    	add_filter('wfu_debug-wfu_get_filtered_recs', 'wfu_get_filtered_recs_alt', 10, 2);
    	$GLOBALS['wfu_debug_end-wfu_get_filtered_recs'] = "1";

    Variable $num defines how many records you want to show in the file viewer.



Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.