In the previous tutorial I showed how we can get the URL of an image field from a Settings page when using Meta Box. This tutorial shows how the same can be done when the image field is inside a group.

FYI: Meta Box is currently running a LTD (lifetime deal) sale at Appsumo. The complete package for unlimited sites for lifetime access with support costs $150. Get Meta Box (affiliate link)

Option name of the Settings page: my_options

Field ID Prefix set for the field group attached to the Settings page: sitewide_

ID of the Group field: branding

ID of the Single Image-type field inside the branding group: logo

Here’s the custom function:

/* Get the URL of group's logo image from the settings page */
function wpdd_get_mb_settings_group_logo_url() {
	// Array of sitewide_branding custom field of the my_options Settings page.
	// Ex.: Array ( [sitewide_logo] => 372 )
	$group_value = rwmb_meta( 'sitewide_branding', ['object_type' => 'setting'], 'my_options' );
	// Value of the sitewide_logo field (image ID in this case).
	// Ex.: 372
	$logo = isset( $group_value['sitewide_logo'] ) ? $group_value['sitewide_logo'] : '';
	// Get the array from image ID.
	// Ex.:
	$logo = RWMB_Image_Field::file_info( $logo );

	// Return URL of the logo image.
	return $logo ? $logo['url'] : 'https://oxygen.local/wp-content/uploads/2021/03/placeholder-logo.png';

When using Oxygen, this can be used via Dynamic Data > PHP Function Return value by setting wpdd_get_mb_settings_group_logo_url as the Function Name.

Replace https://oxygen.local/wp-content/uploads/2021/03/placeholder-logo.png with the URL of a fallback image from your media library.


Need help implementing a tutorial in your site or want to hire me for custom work?


Find the article helpful and wish to donate?



You need to be logged in to view and post comments.
Not a member yet? Join here.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: