BuddyBoss Home – Web › Support Forums › Plugins › BuddyBoss Wall › Auto delete images off server when activity stream update also deleted
Tagged: images
- This topic has 4 replies, 2 contibutors, and was last updated 8 years, 9 months ago by Anonymous.
Question
January 22, 2016 at 3:17 pm #56933@markob17Hi, I’m wondering if anybody could tweak the following function to auto delete images from the server when an activity stream update (in which an image is attached when using the URL preview feature) is deleted. How it is set up now, when an activity stream update is deleted by a member, the URL preview image/images are left on the server wasting disk space. Other than this caveat, the URL preview feature of this plugin is flawless.
I tweaked the following code from a function I found that auto deletes images from posts/custom posts when the post itself is deleted. My coding experience is very limited. I pretty much left the code intact but only added the
$activity_id
variable andbp_activity_action_delete_activity
action thinking it would possibly work. Not sure if I’m even on the right track, I honestly just don’t have the knowledge set to figure this out. Maybe I am totally wrong, but hoping someone can make this work by modifying this function. Appreciate the input!function delete_attachments($activity_id) { $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $activity_id ); $attachments = get_posts($args); if ($attachments) { foreach($attachments as $attachment) { wp_delete_attachment($attachment->ID, true); } } } add_action('bp_activity_action_delete_activity', 'delete_attachments');
Answers
January 25, 2016 at 7:12 am #57110@
AnonymousHi @markob17,
It already inside our suggestion list and attached Activity is not a post type and we can not query like that.
It depends on plugin specific in which way they have linked media to activity.
Like BuddyPress activity plus stores media in different way, and media plugins stores in different way.From wall plugin we can delete only those images which have been posted by url submission.
Regards
January 25, 2016 at 4:32 pm #57159@markob17Hi @vapvarun,
Thank you very much for the clarification and for adding this to your suggestion list, really appreciate it!
Best Regards,
Mark
February 24, 2016 at 3:27 am #60055@markob17Hi @vapvarun, thanks for taking care of this with the recent update! That was a quick turnaround, appreciate it.
Best Regards,
mark
February 24, 2016 at 3:29 am #60056@
AnonymousThanks, I will close this topic
Regards
Varun Dubey
- The question ‘Auto delete images off server when activity stream update also deleted’ is closed to new replies.