Admin plugin to select images from media gallery
-
I have a need to create a custom plugin that will run in a custom post type’s admin/edit screen. Each of the custom post types corresponds to a client, and they each have the ACF image gallery field on their post admin/edit screen so images can be uploaded to this cpt and have a parent attachment relationship.
I would like to add a simple plugin that allows me to select 6-8 images associated with this parent attachment (each client will own their own images, one client’s images will not be used with any other client), and have a button that will submit the selected images and create a different custom post type with the images selected. I feel comfortable retrieving the images on the front end, but I was wondering where the best place to start would be.
ACF confirmed that this could be done if both post types shared the same field types, using this filter:
<?php function my_acf_load_value( $value, $post_id, $field ) { $closetID = "some_value"; if (!$value) { //get value from closet $value = get_field("closet_images", $closetID); update_field( 'order_images', $value, $post_id ); //remove value from closet field update_field( 'closet_images', '', $closetID); } return $value; } add_filter('acf/load_value/name=order_images', 'my_acf_load_value', 10, 3); ?>
So the client post would have 8 ACF image fields, and so would the other custom post type created from the images. Once the images are selected, one by one, using the ACF fields in the client page, I need to call the above filter that takes the images from one post type and creates a new post with the images. The add_filter() above makes sense to me in how it works, but I’m confused on how exactly to call this filter so that it takes the values and creates the other post.
I know it’s not a typical workflow, but if it could work it would make my colleagues very happy. Any direction or advice I appreciate.
- The topic ‘Admin plugin to select images from media gallery’ is closed to new replies.