Tagged: mediapress
Hello,
When I add images to a mediapress gallery with the following code they do not show up in the viewing of the gallery but they do show up in the editing view. I’ve added an image with the “add media” link and in this case they show up in both views. I’ve looked for the difference in the database but I can’t seem to find it. My code follows:
add_action(‘mpp_actions’, ‘add_trailers’);
function add_trailers($gid = 304) {
$gid = 304;
$search_string = ‘gallery_id=’ . $gid;
if (!strstr($_SERVER[‘QUERY_STRING’], $search_string)) return;GLOBAL $wpdb;
//Include image.php for helper functions
require_once ABSPATH . ‘wp-admin/includes/image.php’;remove_all_trailer_images($gid);
//get the included users
$query = “SELECT DISTINCT user_id
FROM wp_mepr_transactions trans
WHERE status = ‘confirmed’
AND txn_type = ‘subscription_confirmation'”;$res = $wpdb->get_results($query);
foreach ($res as $key => $value) {
$users[] = $value->user_id;
}foreach ($users as $key => $value) {
$user_id = $value;
$sister_num = $wpdb->get_var(“SELECT value FROM wp_bp_xprofile_data WHERE field_id = 13 AND user_id = ” . $user_id);
$trailer_image = $wpdb->get_var(“SELECT value FROM wp_bp_xprofile_data WHERE field_id = 7 AND user_id = ” . $user_id);
$trailer_name = $wpdb->get_var(“SELECT value FROM wp_bp_xprofile_data WHERE field_id = 4 AND user_id = ” . $user_id);
$trailer_year = $wpdb->get_var(“SELECT value FROM wp_bp_xprofile_data WHERE field_id = 14 AND user_id = ” . $user_id);
$trailer_make = $wpdb->get_var(“SELECT value FROM wp_bp_xprofile_data WHERE field_id = 15 AND user_id = ” . $user_id);
$trailer_model = $wpdb->get_var(“SELECT value FROM wp_bp_xprofile_data WHERE field_id = 16 AND user_id = ” . $user_id);if (!$sister_num || !$trailer_image || !$trailer_name || !$trailer_year || !$trailer_make || !$trailer_model) continue;
$title = $trailer_name . ‘ – ‘ . $trailer_year . ‘ – ‘ . $trailer_make . ‘ – ‘ . $sister_num . ‘-‘;
$content = ‘Name: ‘ . $trailer_name . ‘ Year: ‘ . $trailer_year . ‘ Make: ‘ . $trailer_make . ‘ Model: ‘ . $trailer_model;
$gallery_id = $gid; //change
$media_type = ‘photo’;
$type = ‘image/jpeg’;
$url = ‘http://sisters.dev/wp-content/uploads’ . $trailer_image;
$file = ‘/wp-content/uploads’ . $trailer_image;
$status = ‘public’;
$component_id = $user_id;
$component = ‘sitewide’;$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,
);mpp_add_media($media_data);
}
}
function remove_all_trailer_images($gallery_id) {
GLOBAL $wpdb;
$q = “SELECT activity_id FROM wp_bp_activity_meta WHERE meta_value = ” . $gallery_id . ” AND meta_key = ‘_mpp_gallery_id'”;
$qu = “SELECT meta_value FROM wp_bp_activity_meta WHERE activity_id IN (” . $q . “) AND meta_key = ‘_mpp_attached_media_id'”;$ret = $wpdb->get_results($qu);
foreach($ret as $key => $value) {
wp_delete_post($value->meta_value);
}}
Hi Paul,
You should most probably not use the component ‘sitewide’ .
Your User gallery and media should use ‘members’ component.Can you please check with that(Please make sure to enable the members component in the backend to avoid any issue).
Hi 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,
PaulHi Paul,
I am sorry for the inconvenience.May I ask you for 2 more things:-
1. Please visit the MediaPress->All Galleries in the dashboard and then click on edit Gallery for the gallery having issues
2. Visit The edit Media tab, is it showing correct status? Status of the gallery?
3. Try clicking save/update under the media list and does that make it visible on the front end?
Thank you
BrajeshHi there-
I’m working with Paul on this project and thought I’d chime in with more details as I’ve configured most of the plugins. We’re 95% there for the entire site’s functionality. Galleries are working great in every case except for this special gallery and would love to get this final piece of the puzzle settled….we’re SO close. 🙂
WHAT THIS GALLERY IS:
———————
Trailer Gallery: Public Gallery – Anyone can view whether logged in or not
It’s images are to be imported from a custom Buddypress Profile field, $field_content_trailer_imageMORE ON WHERE THE IMAGES COME FROM:
—————————
Unlike most galleries, people will not be uploading these trailer images into a specific gallery themselves.Paid Members have a BuddyPress profile and can upload a Trailer Image to their profile in the custom Buddypress field named $field_content_trailer_image.
This Trailer Gallery should then display every Member’s trailer image if they’ve added one to their $field_content_trailer_image profile field
WHAT PUBLIC IS SEEING WITH CODE AS IT IS NOW:
———————————————
From the main /photo-gallery/ page, we DO see the Thumbnail. If we click on the thumbnail, we get the popup that lets you click < and > to scroll thru the Trailer Gallery Images. We see them, this page looks / behaves normally.However, if we click on the links below the thumbnail, the Gallery name or View… we are taken to the Gallery page at /gallery/trailer-gallery and instead of seeing the thumbnails of the individual gallery images like we see on other Public Sitewide Galleries, we get to the url at /gallery/trailer-gallery which says “Nothing to see here!” which is the message the plugin shows when there are no images in a Gallery. We see the thumbs on the main /photo-gallery page and can scroll thru them in the popup on that page so we know we’re ALMOST there…
WHEN VIEWING THE GALLERY LIST PAGE IN BACKEND:
———————————————-
on the page /wp-admin/edit.php?post_type=mpp-galleryAll galleries show a Count in the Media column except for the Trailer Gallery which shows a count of 0. (even though the thumbnail and popup viewer works on /photo-gallery/)
Seems like they’re ALMOST there but the images aren’t fully recognized by MediaPress when setting up a gallery this way.
I JUST NOTICED – THIS MAY BE AN ISSUE
—————————————-
in comment #2922, you said1. Please visit the MediaPress->All Galleries in the dashboard and then click on edit Gallery for the gallery having issues
2. Visit The edit Media tab, is it showing correct status? Status of the gallery?
3. Try clicking save/update under the media list and does that make it visible on the front end?
/wp-admin/post.php?post=275&action=edit#mpp-admin-edit-panel-tab-edit-media
When I go to All Galleries in backend and click Edit Gallery for the Trailer Gallery OR ANY GALLERY FOR THAT MATTER, once the edit screen loads, if I click on the Add Media, Edit Details or Edit Media tab in the Gallery Admin section the url at the top of the screen changes but nothing happens, page doesn’t load or show new info. We also don’t seee any thumbnails or details like I now see from the screenshots on your website, should appear on any Gallery’s Edit screen.
- This reply was modified 8 years, 8 months ago by Horton. Reason: Noticed All Galleries Edit Screens don't show thumbs or allow us to click on Add Media, Edit Details or Edit Media
Hi Paul, Horton,
My apologies for the delayed reply.
I am unable to see a reason why the media is not visible.The only reasons it could be behaving like this is either they are not marked as _mpp_is_mpp_media in the post meta or either the status/component/ype is not set. I am trying to include a debugger in the MediaPress for showing it for individual media. Please allow me to push a release of MediaPress today and using that we might have better idea what is going wrong here.
Thank you
BrajeshBrajesh,
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 Paul,
Thank you.The meta seems fine to me. It is most probably one of the taxonomies(that we use as status/type/component) that is empty and causing this issue. I am on it and should have some way to show them today.
Thank you
Brajesh
You must be logged in to reply to this topic.