This members-only tutorial provides the steps to pull the URL of a random image from the images uploaded to "Image Advanced" type of custom field created using Meta Box so it can be applied as background of a hero section in Oxygen.
For doing the same but with ACF, refer to this tutorial instead.
Install and activate Meta Box.
Go to Meta Box > Custom Fields and add a new field group.
Enter a title like "Page Fields".
Change the label to "Hero Background".
You may leave the auto generated ID as is or change it so it is unique.
Select "Image Advanced" from the Type dropdown.
From the Settings tab, set the field group's Location as Post type = Page (page).
Edit your Pages and populate the field group for each.
Let's create a custom function that takes the field ID and image size handle as arguments and returns the URL of a random image from the supplied field in the specified size.
Install and activate Code Snippets plugin.
Go to Snippets > Add New.
Title: [Function] Get the URL of a random image from the supplied Image Advanced field
This is a premium members-only content.
To view the rest of the content, please sign up for membership ($47/month or $599 one-time).
Already a member? Log in below or here.