[buddypress-trac] [BuddyPress Trac] #6278: Attachment Library

buddypress-trac noreply at wordpress.org
Wed Mar 4 01:02:38 UTC 2015


#6278: Attachment Library
-------------------------+------------------------------------
 Reporter:  imath        |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  2.3
Component:  API          |    Version:
 Severity:  normal       |   Keywords:  has-patch dev-feedback
-------------------------+------------------------------------
 Once upon a time :)

 I've first worked on a component manage attachments for other attachments
 (see #5429)
 It was built as a plugin on our [https://github.com/buddypress/bp-
 attachments github repository]

 Then during WCSF 2014, members of the team who attended this event had a
 [https://bpdevel.wordpress.com/2014/11/12/at-wcsf-some-attendees-of/
 discussion about BuddyPress and ideas for the future].

 On the "Attachments" topic, the discussed road was :
 1. API improvements around handling media (specifically avatars) are long
 overdue.
 2. No appetite for a "photo album" component in core at the moment, but
 our new APIs should be built to let other plugin developers build one
 "easily".
 3. We want to overhaul/rebuild the user avatar upload
 process/cropper/management etc as a first step for a UI change directly
 related to media. Clean-Cole has begin to do some refinement based on
 prior work by @imath

 A bit later, i've worked on a patch on ticket #6004, and it appeared :
 - it was suggesting a lot of changes ( too much :) )
 - the component organization wasn't great, as uploading an avatar would
 require the Attachments component to be active
 - we shouldn't rely on wp.media (at least for the front end part of the
 API)

 The consensus seems to be to work on "attachments" as a core library.
 Avatar would use this library, and so custom BuddyPress
 components/plugins.

 The attached patch is my suggestion for the first step : building an
 "attachment" tool (actually it's mainly dealing with managing uploads) the
 avatar/plugins could use to upload files. For this first patch, i've
 worked with one of my plugin in mind, trying to answer to the question:
 how could BuddyPress help even more BuddyDrive to manage uploads?

 BuddyDrive needs are :
 a) to create a specific directory under `WP_CONTENT` uploads (the
 'buddydrive' folder)
 b) to put the uploaded file in it filtering `'upload_dir'`
 c) to have specific rules when a file is uploaded (each user has a quota
 of "disk space", and mime types can be restricted by Administrator)

 If we look at avatars, we're doing similar things :
 a) we need to create 2 folders 'avatars' & 'group-avatars'
 b) member and group avatars are using specific filters on `'upload_dir'`
 c) only image mime types are allowed

 The BP_Attachment class of the patch is making sure the avatar management
 is working as before, but also allows any plugin sharing BuddyDrive's
 needs to use it to manage their uploads. Like Avatars custom components
 could set up a global in their BP_Component->setup_globals() function and
 then simply use (when needed) :
 {{{
 buddypress()->{component_id}->upload( $file );
 }}}

 I've also thought about the UI changes of the above point 3. I don't know
 if Clean-Cole made progress about it, but working on another plugin (BP
 Avatar Suggestions) gave me an idea. I agree using wp.media on front end
 is not so great: overriding wp.media needs to be done even in wp-pluploads
 as the Attachments model is used in there. So a BuddyPress specific UI
 would be great specially if :
 - it deals with uploads/cropping (of course)
 - but also if it deals with other ways to set a user or a group avatar
 (eg: grabbing a file from an url, or allowing to directly take a photo of
 the user see #5548).
 Anyway i'm too curious about these last points, so i'll explore them :)

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6278>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list