Home › Forums › ACF PRO › Only allow specific image to be selected from the media library › Reply To: Only allow specific image to be selected from the media library
Create a dynamically populated radio field. For choices return an array
// build list of images to allow
// $images contains a list of image IDs
foreach ($images as $image_id) {
$image = wp_get_attachment_image_src($image_id, $size);
$image_tag = '<img src="'.$image[0].'"' width="'.$image[1].'" height="'.$image[2].'"';
$choices[$image_id] = $image_tag;
}
return $choices
for more information see http://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/ this can also be done with radio or checkbox fields.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.