Skip to:
Content
Pages
Categories
Search
Top
Bottom

Is it possible to choose a Cover Image vs. upload one?


  • maccast
    Participant

    @maccast

    I am trying to figure out if there is a way to augment or filter the BuddyPress uploader for cover images. What we want to do is, in addition to allowing uploads, allow our users to choose from a library of already existing images that we have provided. I’ve done a lot of searching and all I can find is instructions for adding a “default” cover image. So is what i want to do possible?

    I assume I would need to hook into the uploader code at some point (or into the Javascript), but I’m not sure where. Any help would be appreciated.

    Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)

  • shanebp
    Moderator

    @shanebp

    If you hook into the uploader, then you’ll be making a copy of an existing file every time a user chooses it, yes? You don’t want that.

    imo…

    You want to remove the existing cover image option.

    You want to create a new tab on their profile and allow them to choose an image.
    Then store their choice as meta data.
    Then rework member-header template so that it loads their chosen image or shows a default one.


    shanebp
    Moderator

    @shanebp

    Oops, sorry, just saw that you want the option in addition to choosing an existing image.

    So, I would do a template overload of this file:
    buddypress\bp-templates\bp-legacy\buddypress\members\single\profile\change-cover-image.php
    And offer them the option of choosing an existing image or upload their own.

    If they choose the latter – use the existing call:
    bp_attachments_get_template_part( 'cover-images/index' );

    And for the former – call in your custom screen as I suggest above and adjust cover-image-header.php to load the appropriate image if that metadata exists for the member.


    maccast
    Participant

    @maccast

    Thanks @shanebp. Yes for sure we would want to avoid the scenario where we are “re-uploading” the default choosen image for each user. I guess I was sort of hoping there was a way in the uploader to just offer them to choose images from our custom library. Sort of like when you use the WordPress media uploader and can choose to pick from the library limiting it to “uploaded to this post”. Overloading the template and using our own custom image picker will work fine. By it being stored in another custom user meta data field it does add some complexity in figuring out how to decide which cover image to use. Meaning that if they upload an image and have also chosen one of our images I need to decide which image takes priority. I’m not sure how I’d do that since meta data fields don;t maintain an “updated” timestamp.


    maccast
    Participant

    @maccast

    I guess one way would be to only show our “default” choices as an option is they have not uploaded or deleted their custom uploaded cover photo.


    shanebp
    Moderator

    @shanebp

    Maybe you could use this hook in buddypress\bp-core\bp-core-attachments.php:
    do_action( $object_data['component'] . '_cover_image_uploaded', (int) $bp_params['item_id'] );

    And delete any existing meta re the choices you provide.


    maccast
    Participant

    @maccast

    That could work. Thanks


    maccast
    Participant

    @maccast

    Just circling back to say this worked like a charm. I wrote a series of functions and added it to a custom plug-in to get it all to work. I’ll try at some point to separate this into a simple stand-alone plugin and try to share it in case someone else needs this feature.


    psnation
    Participant

    @psnation

    I would be interested in a plugin allowing a choice of cover images. Let us know how it turns out.

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Skip to toolbar