Random images from folder in Assets

Silverstripe Version: 4.4

I had function on my old 3 site with ability to take random images from specific folder in assets but this no longer works can you let me know how to update this for Silverstripe 4

public function RandomImage()
{
return DataObject::get_one(“Image”,“ParentID = 360”,false, “RAND()”);
}

In what way isn’t it working? Are there any errors?

You might just need to use the full namespace for the Image class (SilverStripe\Assets\Image) or use Image::class in the method.

Updating it a bit more, you can use:

use SilverStripe\Assets\Image;
use SilverStripe\ORM\DB;

public function getRandomImage() {
  $random = DB::get_conn()->random(); 
  return Image::get_one(Image::class, false, $random);
}