Skip to:
Content
Pages
Categories
Search
Top
Bottom

Override Buddypress AVATAR function in theme


  • nsbrown
    Participant

    @64tees

    Hi

    I’ve changed the CORE_MAX_FILE_SIZE function so the avatar can be larger but I really don’t like thought of editing the plugin files, is there a way I can override this item in my theme functions?

Viewing 13 replies - 1 through 13 (of 13 total)
  • There are a whole series of constants in bp-core-avatar.php that may be overridden, not sure what the constant you mention ‘CORE_MAX_FILE_SIZE’ is


    nsbrown
    Participant

    @64tees

    It defines the sizes of the avatars, large and medium, I’ve set medium to be slightly larger than the original. But I don’t like modifying the core.

    Why don’t these work or am I missing the point .

    `define ( ‘BP_AVATAR_FULL_WIDTH’, 350 );
    define ( ‘BP_AVATAR_FULL_HEIGHT’, 350 );`

    same for thumbs, also of course one can pass size params back on avatar calls.


    nsbrown
    Participant

    @64tees

    Thats how I’ve worked it in the example, but I have to go into plugins/buddypress/ directory to edit that, I want to know if I can copy those parameters over to my functions.php and overwrite the core buddypress ones.

    Know what I mean? I have other functions/declarations that I would like to overwrite, this is just one example

    Those are constants, the whole point of them is that you can set them yourself and override the BP ones as the bp ones check to see if they are defined first somewhere. Try it ou, either in bp-custom.php or functions.php


    nsbrown
    Participant

    @64tees

    Ok I will have a go, I’ll post back my results, cheers!


    nsbrown
    Participant

    @64tees

    Tried pasting the function int my themes functions.php but no joy, hm..

    Functions.php is too late. Use bp-custom.php or wp-config.php.


    nsbrown
    Participant

    @64tees

    I need it in my theme though, so when I distribute it the file will reset the original function


    nsbrown
    Participant

    @64tees

    If I create a bp-custom.php in my theme directory will it work then??

    No bp-custom.php has to run from plugins folder.

    As much as one would expect functions.php to be too late in the proceedings to set a constant that is read it did/does actually work for me to change my user avatars ??

    This issue of being able to effect default ‘stuff’ from themes does crop up from time to time, ideally a method that could ensure things could always be set from functions.php would be great but not sure how or if that is possible with something like Constants which by definition have to be set at earliest opportunity.


    nsbrown
    Participant

    @64tees

    I see, thanks for the info guys!

    @DJPaul Interestingly?

    in my browser output:
    `

    `
    width/height attributes having been set in functions.php:
    `
    define ( ‘BP_AVATAR_FULL_WIDTH’, 450 );
    define ( ‘BP_AVATAR_FULL_HEIGHT’, 450 );
    `

    So it seems as the call for the avatar is a function with params in membere-header.php `bp_displayed_user_avatar( ‘type=full’ )` we are actually forcing conditions to be re parsed and thus picking up my constants in functions.php? however I expected to see somewhere in ‘bp-core-avatars.phh or ‘bp-members-template.php’ a point at which we check for the constants again after the initial setting of them but failed to work out how the function ‘bp_displayed_user_avatar( ‘type=full’ )’ is actually reading the constant. Either I am mis-understanding what’s happening here or I scanned code too quickly and missed what I was looking for.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Override Buddypress AVATAR function in theme’ is closed to new replies.
Skip to toolbar