Replies
Hi Brajesh,
I am using this on a gallery in which the images are added from buddypress fields using mpp_add_media() so I’m guessing since we are using this on a gallery page it’s not a custom page but at the same time all of the images added to this gallery are custom from buddypress fields so I’m not sure.
When I interact with MPP_Media_Query class using one of the loop styles described in the documentation you suggested where would you suggest I place that ocde? In the same plugin I created to populate the gallery with mpp_add_media? Which action would you suggest I use? Would I create the actual search box with html? How do I retrieve the submitted vars? There is no explanation of the “$args” variable. Can you give me a bit more insight to this: “It uses parent::query() and only allows limited options with query.”
Thanks,
PaulBrajesh,
I looked into the meta info for one of the problem images:
get_post_meta(1040
”
array(3) {
[“_wp_attached_file”]=>
array(1) {
[0]=>
string(44) “/wp-content/uploads/profiles/15/IMG_3877.jpg”
}
[“_mpp_component_id”]=>
array(1) {
[0]=>
string(2) “15”
}
[“_mpp_is_mpp_media”]=>
array(1) {
[0]=>
string(1) “1”
}
}They appear to have the meta content you specified. I know you are working on a debugger but I thought this might be helpful.
Thank You,
PaulHi Brajesh,
I did as you instructed:
1. Changed the component var from ‘sitewide’ to ‘members’
2. Acted on a galley that used the ‘members’ componentI experienced the same results, I see the images I add ONLY in the “Edit Media” view. Changing the component doesn’t make any difference that I can see.
Thanks,
PaulHello Brajesh,
Thank you for the very helpful reply. The following code does add the image to the gallery but with a few problems.
1. Clicking on the image does not work, I get an “The page isn’t redirecting properly” error.
2. I get wsod when running the script. After I comment out $id = mpp_add_media( $media_data ); and return to the gallery the image is there.I will also need to roll through the images in the gallery to remove unwanted images.
add_action(‘init’, ‘add_member_images’);
function add_member_images() {$title = ‘testing image’;
$content = ‘checking this out’;
$gallery_id = 292;
$media_type = ‘photo’;
$type = ‘image/jpeg’;
$url = ‘http://sisters.dev/wp-content/uploads/profiles/4/large_22097.jpg’;
$file = ‘/wp-content/uploads/profiles/4/large_22097.jpg’;
$status = ‘public’;
$component_id = 1;
$component = ‘members’;$media_data = array(
‘title’ => $title,
‘description’ => $content,
‘gallery_id’ => $gallery_id,
‘user_id’ => get_current_user_id(),
‘is_remote’ => false,
‘type’ => $media_type,
‘mime_type’ => $type,
‘src’ => $file,
‘url’ => $url,
‘status’ => $status,
‘comment_status’ => ‘open’,
‘storage_method’ => mpp_get_storage_method(),
‘component_id’ => $component_id,
‘component’ => $component,
//’context’ => $context,
‘is_orphan’ => 0,
);//$id = mpp_add_media( $media_data );
}
Thank You,
Paul- This reply was modified 8 years, 9 months ago by Paul.
Brajesh, thank you so much for the quick reply. I have a buddypress site with members via memberpress. I need to make sure they are a paying member and if they are add images and a few other fields from their buddypress profile to a custom gallery. In a new plugin I have tried the following code as a test but it breaks the site:
add_action(‘mpp_loaded’, ‘add_member_images’);
function add_member_images() {$args = array(
‘gallery_id’ => 292,
‘title’ => ‘testing’,
‘type’ => ‘image’,
);$ret = mpp_add_media($args);
}
I assume I pass the image and other fields as args? If so how do I specify the image? Maybe I way off here? I would appreciate any help.