Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/16/2015 10:11:05 PM (10 years ago)
Author:
imath
Message:

Avatar UI: Add Conditional functions and new BP Attachment methods

  • bp_avatar_is_front_edit() checks if the user is editing his or a group avatar on front-end
  • bp_avatar_use_webcam() checks if the Camera feature should be enabled. By default, it is not the case for touch devices as it can introduce some confustions with the possibility of using the camera of the device to take a selfie, save it as an image an upload it using the Browse button of the Avatar UI. Chrome and Firefox are the only browsers supporting getUserMedia.

NB: these two functions can be filtered to disallow the Camera feature or to completely disallow the new Avatar UI if you prefer to carry on using the legacy UI.

BP_Attachment::script_data() and BP_Attachment_Avatar::script_data() are two new methods to build the javascript localization data. The bp_attachment_avatar_params filter is fired if the current object is not a group or a user and can be used to build the params of another object such as a blog. You can also use the filter bp_attachment_avatar_script_data if you need to override data for any object.

Props boonebgorges, DJPaul.

See #6290
See #6278

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-attachment.php

    r9660 r9755  
    478478        return wp_crop_image( $r['original_file'], (int) $r['crop_x'], (int) $r['crop_y'], (int) $r['crop_w'], (int) $r['crop_h'], (int) $r['dst_w'], (int) $r['dst_h'], $r['src_abs'], $r['dst_file'] );
    479479    }
     480
     481    /**
     482     * Build script datas for the Uploader UI
     483     *
     484     * Override this method from your child class to build the script datas
     485     *
     486     * @since BuddyPress (2.3.0)
     487     *
     488     * @return array the javascript localization data
     489     */
     490    public function script_data() {
     491        $script_data = array(
     492            'action'            => $this->action,
     493            'file_data_name'    => $this->file_input,
     494            'max_file_size'     => $this->original_max_filesize,
     495            'feedback_messages' => array(
     496                1 => __( 'Sorry, uploading the file failed.', 'buddypress' ),
     497                2 => __( 'File successfully uploaded.', 'buddypress' ),
     498            ),
     499        );
     500
     501        return $script_data;
     502    }
    480503}
Note: See TracChangeset for help on using the changeset viewer.