Support

Account

Home Forums ACF PRO Only allow specific image to be selected from the media library

Helping

Only allow specific image to be selected from the media library

  • Hi

    Is it possible to allow only specific images to be chosen from the media library?

    e.g.

    I have custom post type ‘example post’. I allow users with a specific user role to create a new ‘example post’ from the front-end. I have the image field where they can choose an image from the image library; however I don’t want them to be able to select from every image that has been uploaded. I want to be able to choose what images will be available as an option. Is this possible?

  • 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.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Only allow specific image to be selected from the media library’ is closed to new replies.