当前位置: 首页>>代码示例>>PHP>>正文


PHP bp_core_avatar_full_width函数代码示例

本文整理汇总了PHP中bp_core_avatar_full_width函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_core_avatar_full_width函数的具体用法?PHP bp_core_avatar_full_width怎么用?PHP bp_core_avatar_full_width使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bp_core_avatar_full_width函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: revert_to_default_wp_avatar

function revert_to_default_wp_avatar($img, $params, $item_id)
{
    // we are concerned only with users
    if ($params['object'] != 'user') {
        return $img;
    }
    //check if user has uploaded an avatar
    //if not then revert back to wordpress core get_avatar method
    //remove the filter first, or else it will go in infinite loop
    remove_filter('bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3);
    if (!userpro_user_has_avatar($item_id)) {
        $width = $params['width'];
        // Set image width
        if (false !== $width) {
            $img_width = $width;
        } elseif ('thumb' == $type) {
            $img_width = bp_core_avatar_thumb_width();
        } else {
            $img_width = bp_core_avatar_full_width();
        }
        $img = get_avatar($item_id, $img_width);
    }
    //add the filter back again
    add_filter('bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3);
    return $img;
}
开发者ID:ingridlima,项目名称:userpro-custom,代码行数:26,代码来源:buddypress.php

示例2: revert_to_default_wp_avatar

function revert_to_default_wp_avatar($img, $params, $item_id)
{
    if ($params['object'] != 'user') {
        return $img;
    }
    remove_filter('bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3);
    if (!userpro_user_has_avatar($item_id)) {
        $width = $params['width'];
        if (false !== $width) {
            $img_width = $width;
        } elseif ('thumb' == $params['type']) {
            $img_width = bp_core_avatar_thumb_width();
        } else {
            $img_width = bp_core_avatar_full_width();
        }
        $img = get_avatar($item_id, $img_width);
    }
    add_filter('bp_core_fetch_avatar', 'revert_to_default_wp_avatar', 80, 3);
    return $img;
}
开发者ID:httvncoder,项目名称:151722441,代码行数:20,代码来源:buddypress.php

示例3: bp_get_signup_avatar

/**
 * Get the user avatar during signup.
 *
 * @see bp_core_fetch_avatar() for description of arguments.
 *
 * @param array|string $args {
 *     Array of optional arguments.
 *     @type int    $size  Height/weight in pixels. Default: value of
 *                         bp_core_avatar_full_width().
 *     @type string $class CSS class. Default: 'avatar'.
 *     @type string $alt   HTML 'alt' attribute. Default: 'Your Avatar'.
 * }
 * @return string
 */
function bp_get_signup_avatar($args = '')
{
    $bp = buddypress();
    $defaults = array('size' => bp_core_avatar_full_width(), 'class' => 'avatar', 'alt' => __('Your Profile Photo', 'buddypress'));
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    // Avatar DIR is found.
    if ($signup_avatar_dir = bp_get_signup_avatar_dir_value()) {
        $gravatar_img = bp_core_fetch_avatar(array('item_id' => $signup_avatar_dir, 'object' => 'signup', 'avatar_dir' => 'avatars/signups', 'type' => 'full', 'width' => $size, 'height' => $size, 'alt' => $alt, 'class' => $class));
        // No avatar DIR was found.
    } else {
        // Set default gravatar type.
        if (empty($bp->grav_default->user)) {
            $default_grav = 'wavatar';
        } elseif ('mystery' == $bp->grav_default->user) {
            $default_grav = $bp->plugin_url . 'bp-core/images/mystery-man.jpg';
        } else {
            $default_grav = $bp->grav_default->user;
        }
        /**
         * Filters the base Gravatar url used for signup avatars when no avatar dir found.
         *
         * @since 1.0.2
         *
         * @param string $value Gravatar url to use.
         */
        $gravatar_url = apply_filters('bp_gravatar_url', '//www.gravatar.com/avatar/');
        $md5_lcase_email = md5(strtolower(bp_get_signup_email_value()));
        $gravatar_img = '<img src="' . $gravatar_url . $md5_lcase_email . '?d=' . $default_grav . '&amp;s=' . $size . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
    }
    /**
     * Filters the user avatar during signup.
     *
     * @since 1.1.0
     *
     * @param string $gravatar_img Avatar HTML image tag.
     * @param array  $args         Array of parsed args for avatar query.
     */
    return apply_filters('bp_get_signup_avatar', $gravatar_img, $args);
}
开发者ID:mawilliamson,项目名称:wordpress,代码行数:54,代码来源:bp-members-template.php

示例4: bp_get_signup_avatar

function bp_get_signup_avatar($args = '')
{
    global $bp;
    $defaults = array('size' => bp_core_avatar_full_width(), 'class' => 'avatar', 'alt' => __('Your Avatar', 'buddypress'));
    $r = nxt_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    // Avatar DIR is found
    if ($signup_avatar_dir = bp_get_signup_avatar_dir_value()) {
        $gravatar_img = bp_core_fetch_avatar(array('item_id' => $signup_avatar_dir, 'object' => 'signup', 'avatar_dir' => 'avatars/signups', 'type' => 'full', 'width' => $size, 'height' => $size, 'alt' => $alt, 'class' => $class));
        // No avatar DIR was found
    } else {
        // Set default gravatar type
        if (empty($bp->grav_default->user)) {
            $default_grav = 'wavatar';
        } else {
            if ('mystery' == $bp->grav_default->user) {
                $default_grav = BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg';
            } else {
                $default_grav = $bp->grav_default->user;
            }
        }
        // Create
        $gravatar_url = apply_filters('bp_gravatar_url', 'http://www.gravatar.com/avatar/');
        $md5_lcase_email = md5(strtolower(bp_get_signup_email_value()));
        $gravatar_img = '<img src="' . $gravatar_url . $md5_lcase_email . '?d=' . $default_grav . '&amp;s=' . $size . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
    }
    return apply_filters('bp_get_signup_avatar', $gravatar_img, $args);
}
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:28,代码来源:bp-members-template.php

示例5: bp_core_avatar_handle_crop

/**
 * Crop an uploaded avatar
 *
 * $args has the following parameters:
 *  object - What component the avatar is for, e.g. "user"
 *  avatar_dir  The absolute path to the avatar
 *  item_id - Item ID
 *  original_file - The absolute path to the original avatar file
 *  crop_w - Crop width
 *  crop_h - Crop height
 *  crop_x - The horizontal starting point of the crop
 *  crop_y - The vertical starting point of the crop
 *
 * @global object $bp BuddyPress global settings
 * @param mixed $args
 * @return bool Success/failure
 */
function bp_core_avatar_handle_crop($args = '')
{
    global $bp;
    $defaults = array('object' => 'user', 'avatar_dir' => 'avatars', 'item_id' => false, 'original_file' => false, 'crop_w' => bp_core_avatar_full_width(), 'crop_h' => bp_core_avatar_full_height(), 'crop_x' => 0, 'crop_y' => 0);
    $r = nxt_parse_args($args, $defaults);
    /***
     * You may want to hook into this filter if you want to override this function.
     * Make sure you return false.
     */
    if (!apply_filters('bp_core_pre_avatar_handle_crop', true, $r)) {
        return true;
    }
    extract($r, EXTR_SKIP);
    if (!$original_file) {
        return false;
    }
    $original_file = bp_core_avatar_upload_path() . $original_file;
    if (!file_exists($original_file)) {
        return false;
    }
    if (!$item_id) {
        $avatar_folder_dir = apply_filters('bp_core_avatar_folder_dir', dirname($original_file), $item_id, $object, $avatar_dir);
    } else {
        $avatar_folder_dir = apply_filters('bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir);
    }
    if (!file_exists($avatar_folder_dir)) {
        return false;
    }
    require_once ABSPATH . '/nxt-admin/includes/image.php';
    require_once ABSPATH . '/nxt-admin/includes/file.php';
    // Delete the existing avatar files for the object
    bp_core_delete_existing_avatar(array('object' => $object, 'avatar_path' => $avatar_folder_dir));
    // Make sure we at least have a width and height for cropping
    if (!(int) $crop_w) {
        $crop_w = bp_core_avatar_full_width();
    }
    if (!(int) $crop_h) {
        $crop_h = bp_core_avatar_full_height();
    }
    // Set the full and thumb filenames
    $full_filename = nxt_hash($original_file . time()) . '-bpfull.jpg';
    $thumb_filename = nxt_hash($original_file . time()) . '-bpthumb.jpg';
    // Crop the image
    $full_cropped = nxt_crop_image($original_file, (int) $crop_x, (int) $crop_y, (int) $crop_w, (int) $crop_h, bp_core_avatar_full_width(), bp_core_avatar_full_height(), false, $avatar_folder_dir . '/' . $full_filename);
    $thumb_cropped = nxt_crop_image($original_file, (int) $crop_x, (int) $crop_y, (int) $crop_w, (int) $crop_h, bp_core_avatar_thumb_width(), bp_core_avatar_thumb_height(), false, $avatar_folder_dir . '/' . $thumb_filename);
    // Remove the original
    @unlink($original_file);
    return true;
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:66,代码来源:bp-core-avatars.php

示例6: bp_blogs_update_option_site_icon

/**
 * Syncs site icon URLs to blogmeta.
 *
 * @since 2.7.0
 *
 * @param int|string $old_value Old value
 * @param int|string $new_value New value
 */
function bp_blogs_update_option_site_icon($old_value, $new_value)
{
    if (0 === $new_value) {
        bp_blogs_update_blogmeta(get_current_blog_id(), 'site_icon_url_thumb', 0);
        bp_blogs_update_blogmeta(get_current_blog_id(), 'site_icon_url_full', 0);
    } else {
        // Save site icon URL as blogmeta.
        bp_blogs_update_blogmeta(get_current_blog_id(), 'site_icon_url_thumb', get_site_icon_url(bp_core_avatar_thumb_width()));
        bp_blogs_update_blogmeta(get_current_blog_id(), 'site_icon_url_full', get_site_icon_url(bp_core_avatar_full_width()));
    }
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:19,代码来源:bp-blogs-functions.php

示例7: bp_core_add_cropper_inline_css

/**
 * bp_core_add_cropper_inline_css()
 *
 * Adds the inline CSS needed for the cropper to work on a per-page basis.
 *
 * @package BuddyPress Core
 */
function bp_core_add_cropper_inline_css()
{
    global $bp;
    ?>

	<style type="text/css">
		.jcrop-holder { float: left; margin: 0 20px 20px 0; text-align: left; }
		.jcrop-vline, .jcrop-hline { font-size: 0; position: absolute; background: white top left repeat url( <?php 
    echo BP_PLUGIN_URL;
    ?>
/bp-core/images/Jcrop.gif ); }
		.jcrop-vline { height: 100%; width: 1px !important; }
		.jcrop-hline { width: 100%; height: 1px !important; }
		.jcrop-handle { font-size: 1px; width: 7px !important; height: 7px !important; border: 1px #eee solid; background-color: #333; *width: 9px; *height: 9px; }
		.jcrop-tracker { width: 100%; height: 100%; }
		.custom .jcrop-vline, .custom .jcrop-hline { background: yellow; }
		.custom .jcrop-handle { border-color: black; background-color: #C7BB00; -moz-border-radius: 3px; -webkit-border-radius: 3px; }
		#avatar-crop-pane { width: <?php 
    echo bp_core_avatar_full_width();
    ?>
px; height: <?php 
    echo bp_core_avatar_full_height();
    ?>
px; overflow: hidden; }
		#avatar-crop-submit { margin: 20px 0; }
		#avatar-upload-form img, #create-group-form img, #group-settings-form img { border: none !important; }
	</style>

<?php 
}
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:37,代码来源:bp-core-cssjs.php

示例8: crop

 /**
  * Crop the avatar.
  *
  * @since 2.3.0
  *
  * @see  BP_Attachment::crop for the list of parameters
  * @uses bp_core_fetch_avatar()
  * @uses bp_core_delete_existing_avatar()
  * @uses bp_core_avatar_full_width()
  * @uses bp_core_avatar_full_height()
  * @uses bp_core_avatar_dimension()
  * @uses BP_Attachment::crop
  *
  * @param array $args Array of arguments for the cropping.
  * @return array The cropped avatars (full and thumb).
  */
 public function crop($args = array())
 {
     // Bail if the original file is missing.
     if (empty($args['original_file'])) {
         return false;
     }
     /**
      * Original file is a relative path to the image
      * eg: /avatars/1/avatar.jpg
      */
     $relative_path = $args['original_file'];
     $absolute_path = $this->upload_path . $relative_path;
     // Bail if the avatar is not available.
     if (!file_exists($absolute_path)) {
         return false;
     }
     if (empty($args['item_id'])) {
         /** This filter is documented in bp-core/bp-core-avatars.php */
         $avatar_folder_dir = apply_filters('bp_core_avatar_folder_dir', dirname($absolute_path), $args['item_id'], $args['object'], $args['avatar_dir']);
     } else {
         /** This filter is documented in bp-core/bp-core-avatars.php */
         $avatar_folder_dir = apply_filters('bp_core_avatar_folder_dir', $this->upload_path . '/' . $args['avatar_dir'] . '/' . $args['item_id'], $args['item_id'], $args['object'], $args['avatar_dir']);
     }
     // Bail if the avatar folder is missing for this item_id.
     if (!file_exists($avatar_folder_dir)) {
         return false;
     }
     // Delete the existing avatar files for the object.
     $existing_avatar = bp_core_fetch_avatar(array('object' => $args['object'], 'item_id' => $args['item_id'], 'html' => false));
     /**
      * Check that the new avatar doesn't have the same name as the
      * old one before deleting
      */
     if (!empty($existing_avatar) && $existing_avatar !== $this->url . $relative_path) {
         bp_core_delete_existing_avatar(array('object' => $args['object'], 'item_id' => $args['item_id'], 'avatar_path' => $avatar_folder_dir));
     }
     // Make sure we at least have minimal data for cropping.
     if (empty($args['crop_w'])) {
         $args['crop_w'] = bp_core_avatar_full_width();
     }
     if (empty($args['crop_h'])) {
         $args['crop_h'] = bp_core_avatar_full_height();
     }
     // Get the file extension.
     $data = @getimagesize($absolute_path);
     $ext = $data['mime'] == 'image/png' ? 'png' : 'jpg';
     $args['original_file'] = $absolute_path;
     $args['src_abs'] = false;
     $avatar_types = array('full' => '', 'thumb' => '');
     foreach ($avatar_types as $key_type => $type) {
         if ('thumb' === $key_type) {
             $args['dst_w'] = bp_core_avatar_thumb_width();
             $args['dst_h'] = bp_core_avatar_thumb_height();
         } else {
             $args['dst_w'] = bp_core_avatar_full_width();
             $args['dst_h'] = bp_core_avatar_full_height();
         }
         $args['dst_file'] = $avatar_folder_dir . '/' . wp_hash($absolute_path . time()) . '-bp' . $key_type . '.' . $ext;
         $avatar_types[$key_type] = parent::crop($args);
     }
     // Remove the original.
     @unlink($absolute_path);
     // Return the full and thumb cropped avatars.
     return $avatar_types;
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:81,代码来源:class-bp-attachment-avatar.php

示例9: bp_core_avatar_default

/**
 * Get the URL of the 'full' default avatar.
 *
 * @since 1.5.0
 * @since 2.6.0 Introduced `$params` and `$object_type` parameters.
 *
 * @param string $type   'local' if the fallback should be the locally-hosted version
 *                       of the mystery person, 'gravatar' if the fallback should be
 *                       Gravatar's version. Default: 'gravatar'.
 * @param array  $params Parameters passed to bp_core_fetch_avatar().
 * @return string The URL of the default avatar.
 */
function bp_core_avatar_default($type = 'gravatar', $params = array())
{
    // Local override.
    if (defined('BP_AVATAR_DEFAULT')) {
        $avatar = BP_AVATAR_DEFAULT;
        // Use the local default image.
    } elseif ('local' === $type) {
        $size = '';
        if (isset($params['type']) && 'thumb' === $params['type'] && bp_core_avatar_thumb_width() <= 50 || isset($params['width']) && $params['width'] <= 50) {
            $size = '-50';
        }
        $avatar = buddypress()->plugin_url . "bp-core/images/mystery-man{$size}.jpg";
        // Use Gravatar's mystery person as fallback.
    } else {
        $size = '';
        if (isset($params['type']) && 'thumb' === $params['type']) {
            $size = bp_core_avatar_thumb_width();
        } else {
            $size = bp_core_avatar_full_width();
        }
        $avatar = '//www.gravatar.com/avatar/00000000000000000000000000000000?d=mm&amp;s=' . $size;
    }
    /**
     * Filters the URL of the 'full' default avatar.
     *
     * @since 1.5.0
     * @since 2.6.0 Added `$params`.
     *
     * @param string $avatar URL of the default avatar.
     * @param array  $params Params provided to bp_core_fetch_avatar().
     */
    return apply_filters('bp_core_avatar_default', $avatar, $params);
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:45,代码来源:bp-core-avatars.php

示例10: bp_get_blog_avatar

/**
 * Get a blog's avatar.
 *
 * At the moment, blog avatars are simply the user avatars of the blog
 * admin. Filter 'bp_get_blog_avatar_' . $blog_id to customize.
 *
 * @since 2.4.0 Introduced `$title` argument.
 *
 * @see bp_core_fetch_avatar() For a description of arguments and
 *      return values.
 *
 * @param array|string $args  {
 *     Arguments are listed here with an explanation of their defaults.
 *     For more information about the arguments, see
 *     {@link bp_core_fetch_avatar()}.
 *     @type string   $alt     Default: 'Profile picture of site author [user name]'.
 *     @type string   $class   Default: 'avatar'.
 *     @type string   $title   Default: 'Profile picture of site author [user name]'.
 *     @type string   $type    Default: 'full'.
 *     @type int|bool $width   Default: false.
 *     @type int|bool $height  Default: false.
 *     @type bool     $id      Currently unused.
 *     @type bool     $no_grav Default: true.
 * }
 * @return string User avatar string.
 */
function bp_get_blog_avatar($args = '')
{
    global $blogs_template;
    // Bail if avatars are turned off
    // @todo Should we maybe still filter this?
    if (!buddypress()->avatar->show_avatars) {
        return false;
    }
    $author_displayname = bp_core_get_user_displayname($blogs_template->blog->admin_user_id);
    // Parse the arguments.
    $r = bp_parse_args($args, array('type' => 'full', 'width' => false, 'height' => false, 'class' => 'avatar', 'title' => sprintf(__('Profile picture of site author %s', 'buddypress'), esc_attr($author_displayname)), 'id' => false, 'alt' => sprintf(__('Profile picture of site author %s', 'buddypress'), esc_attr($author_displayname)), 'no_grav' => true));
    // Use site icon if available.
    $avatar = '';
    if (bp_is_active('blogs', 'site-icon') && function_exists('has_site_icon')) {
        $site_icon = bp_blogs_get_blogmeta(bp_get_blog_id(), "site_icon_url_{$r['type']}");
        // Never attempted to fetch site icon before; do it now!
        if ('' === $site_icon) {
            switch_to_blog(bp_get_blog_id());
            // Fetch the other size first.
            if ('full' === $r['type']) {
                $size = bp_core_avatar_thumb_width();
                $save_size = 'thumb';
            } else {
                $size = bp_core_avatar_full_width();
                $save_size = 'full';
            }
            $site_icon = get_site_icon_url($size);
            // Empty site icons get saved as integer 0.
            if (empty($site_icon)) {
                $site_icon = 0;
            }
            // Sync site icon for other size to blogmeta.
            bp_blogs_update_blogmeta(bp_get_blog_id(), "site_icon_url_{$save_size}", $site_icon);
            // Now, fetch the size we want.
            if (0 !== $site_icon) {
                $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width();
                $site_icon = get_site_icon_url($size);
            }
            // Sync site icon to blogmeta.
            bp_blogs_update_blogmeta(bp_get_blog_id(), "site_icon_url_{$r['type']}", $site_icon);
            restore_current_blog();
        }
        // We have a site icon.
        if (!is_numeric($site_icon)) {
            if (empty($r['width']) && !isset($size)) {
                $size = 'full' === $r['type'] ? bp_core_avatar_full_width() : bp_core_avatar_thumb_width();
            } else {
                $size = (int) $r['width'];
            }
            $avatar = sprintf('<img src="%1$s" class="%2$s" width="%3$s" height="%3$s" alt="%4$s" title="%4$s" />', esc_url($site_icon), esc_attr("{$r['class']} avatar-{$size}"), esc_attr($size), sprintf(esc_attr__('Site icon for %s', 'buddypress'), bp_get_blog_name()));
        }
    }
    // Fallback to user ID avatar.
    if ('' === $avatar) {
        $avatar = bp_core_fetch_avatar(array('item_id' => $blogs_template->blog->admin_user_id, 'title' => $r['title'], 'type' => $r['type'], 'alt' => $r['alt'], 'css_id' => $r['id'], 'class' => $r['class'], 'width' => $r['width'], 'height' => $r['height']));
    }
    /**
     * In future BuddyPress versions you will be able to set the avatar for a blog.
     * Right now you can use a filter with the ID of the blog to change it if you wish.
     * By default it will return the avatar for the primary blog admin.
     *
     * This filter is deprecated as of BuddyPress 1.5 and may be removed in a future version.
     * Use the 'bp_get_blog_avatar' filter instead.
     */
    $avatar = apply_filters('bp_get_blog_avatar_' . $blogs_template->blog->blog_id, $avatar);
    /**
     * Filters a blog's avatar.
     *
     * @since 1.5.0
     *
     * @param string $avatar  Formatted HTML <img> element, or raw avatar
     *                        URL based on $html arg.
     * @param int    $blog_id ID of the blog whose avatar is being displayed.
     * @param array  $r       Array of arguments used when fetching avatar.
//.........这里部分代码省略.........
开发者ID:buddypress,项目名称:BuddyPress-build,代码行数:101,代码来源:bp-blogs-template.php

示例11: bp_core_avatar_handle_crop

/**
 * Crop an uploaded avatar
 *
 * $args has the following parameters:
 *  object - What component the avatar is for, e.g. "user"
 *  avatar_dir  The absolute path to the avatar
 *  item_id - Item ID
 *  original_file - The absolute path to the original avatar file
 *  crop_w - Crop width
 *  crop_h - Crop height
 *  crop_x - The horizontal starting point of the crop
 *  crop_y - The vertical starting point of the crop
 *
 * @param mixed $args
 * @return bool Success/failure
 */
function bp_core_avatar_handle_crop($args = '')
{
    $r = wp_parse_args($args, array('object' => 'user', 'avatar_dir' => 'avatars', 'item_id' => false, 'original_file' => false, 'crop_w' => bp_core_avatar_full_width(), 'crop_h' => bp_core_avatar_full_height(), 'crop_x' => 0, 'crop_y' => 0));
    /***
     * You may want to hook into this filter if you want to override this function.
     * Make sure you return false.
     */
    if (!apply_filters('bp_core_pre_avatar_handle_crop', true, $r)) {
        return true;
    }
    extract($r, EXTR_SKIP);
    if (empty($original_file)) {
        return false;
    }
    $original_file = bp_core_avatar_upload_path() . $original_file;
    if (!file_exists($original_file)) {
        return false;
    }
    if (empty($item_id)) {
        $avatar_folder_dir = apply_filters('bp_core_avatar_folder_dir', dirname($original_file), $item_id, $object, $avatar_dir);
    } else {
        $avatar_folder_dir = apply_filters('bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir);
    }
    if (!file_exists($avatar_folder_dir)) {
        return false;
    }
    require_once ABSPATH . '/wp-admin/includes/image.php';
    require_once ABSPATH . '/wp-admin/includes/file.php';
    // Delete the existing avatar files for the object
    bp_core_delete_existing_avatar(array('object' => $object, 'avatar_path' => $avatar_folder_dir));
    // Make sure we at least have a width and height for cropping
    if (empty($crop_w)) {
        $crop_w = bp_core_avatar_full_width();
    }
    if (empty($crop_h)) {
        $crop_h = bp_core_avatar_full_height();
    }
    // Get the file extension
    $data = @getimagesize($original_file);
    $ext = $data['mime'] == 'image/png' ? 'png' : 'jpg';
    // Set the full and thumb filenames
    $full_filename = wp_hash($original_file . time()) . '-bpfull.' . $ext;
    $thumb_filename = wp_hash($original_file . time()) . '-bpthumb.' . $ext;
    // Crop the image
    $full_cropped = wp_crop_image($original_file, (int) $crop_x, (int) $crop_y, (int) $crop_w, (int) $crop_h, bp_core_avatar_full_width(), bp_core_avatar_full_height(), false, $avatar_folder_dir . '/' . $full_filename);
    $thumb_cropped = wp_crop_image($original_file, (int) $crop_x, (int) $crop_y, (int) $crop_w, (int) $crop_h, bp_core_avatar_thumb_width(), bp_core_avatar_thumb_height(), false, $avatar_folder_dir . '/' . $thumb_filename);
    // Check for errors
    if (empty($full_cropped) || empty($thumb_cropped) || is_wp_error($full_cropped) || is_wp_error($thumb_cropped)) {
        return false;
    }
    // Remove the original
    @unlink($original_file);
    return true;
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:70,代码来源:bp-core-avatars.php

示例12: bcp_core_avatar_handle_crop

/**
 * Crop an uploaded avatar.
 * 
 * originally from bp file <>. It was copied since naming it does not have any filters
 * for renaming and changing the cropped avatae
 *
 *  $args has the following parameters:
 *  object - What component the avatar is for, e.g. "user"
 *  avatar_dir  The absolute path to the avatar
 *  item_id - Item ID
 *  original_file - The absolute path to the original avatar file
 *  crop_w - Crop width
 *  crop_h - Crop height
 *  crop_x - The horizontal starting point of the crop
 *  crop_y - The vertical starting point of the crop
 *
 * @param array $args {
 *     Array of function parameters.
 *     @type string $object Object type of the item whose avatar you're
 *           handling. 'user', 'group', 'blog', or custom. Default: 'user'.
 *     @type string $avatar_dir Subdirectory where avatar should be stored.
 *           Default: 'avatars'.
 *     @type bool|int $item_id ID of the item that the avatar belongs to.
 *     @type bool|string $original_file Absolute papth to the original avatar
 *           file.
 *     @type int $crop_w Crop width. Default: the global 'full' avatar width,
 *           as retrieved by bp_core_avatar_full_width().
 *     @type int $crop_h Crop height. Default: the global 'full' avatar height,
 *           as retrieved by bp_core_avatar_full_height().
 *     @type int $crop_x The horizontal starting point of the crop. Default: 0.
 *     @type int $crop_y The vertical starting point of the crop. Default: 0.
 * }
 * @return bool True on success, false on failure.
 */
function bcp_core_avatar_handle_crop($args = '')
{
    $existing_avatar = '';
    $coverphoto_full_width = BCP_MAX_WIDTH;
    $coverphoto_full_height = BCP_MAX_HEIGHT;
    $coverphoto_thumb_full_width = BCP_THUMB_MAX_WIDTH;
    $coverphoto_thumb_full_height = BCP_THUMB_MAX_HEIGHT;
    $r = wp_parse_args($args, array('object' => 'user', 'avatar_dir' => 'avatars', 'item_id' => false, 'original_file' => false, 'crop_w' => bp_core_avatar_full_width(), 'crop_h' => bp_core_avatar_full_height(), 'crop_x' => 0, 'crop_y' => 0));
    /***
     * You may want to hook into this filter if you want to override this function.
     * Make sure you return false.
     */
    if (!apply_filters('bp_core_pre_avatar_handle_crop', true, $r)) {
        return true;
    }
    extract($r, EXTR_SKIP);
    if (empty($original_file)) {
        return false;
    }
    $original_file = bp_core_avatar_upload_path() . $original_file;
    if (!file_exists($original_file)) {
        return false;
    }
    if (empty($item_id)) {
        $avatar_folder_dir = apply_filters('bp_core_avatar_folder_dir', dirname($original_file), $item_id, $object, $avatar_dir);
    } else {
        $avatar_folder_dir = apply_filters('bp_core_avatar_folder_dir', bp_core_avatar_upload_path() . '/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir);
    }
    if (!file_exists($avatar_folder_dir)) {
        return false;
    }
    require_once ABSPATH . '/wp-admin/includes/image.php';
    require_once ABSPATH . '/wp-admin/includes/file.php';
    // Delete the existing avatar files for the object
    $args = array('object_id' => $item_id, 'type' => 'user');
    //change object type to groups for groups
    if ('group-avatars' == $avatar_dir) {
        $args['type'] = 'groups';
    }
    $existing_covers = bcp_fetch_cover_photo($args);
    if (!empty($existing_covers)) {
        // Check that the new avatar doesn't have the same name as the
        // old one before deleting
        $upload_dir = wp_upload_dir();
        $existing_avatar_path = str_replace($upload_dir['baseurl'], '', $existing_avatar);
        $new_avatar_path = str_replace($upload_dir['basedir'], '', $original_file);
        if ($existing_avatar_path !== $new_avatar_path) {
            if ($handle = opendir($avatar_folder_dir)) {
                while (false !== ($entry = readdir($handle))) {
                    if ($entry != "." && $entry != "..") {
                        $file_info = pathinfo($entry);
                        $file_name = $file_info['filename'];
                        $file_ext = $file_info['extension'];
                        $cover_photos = array('coverphoto-full', 'coverphoto-thumb');
                        if (in_array($file_name, $cover_photos)) {
                            // cover photo exists
                            $file = $avatar_folder_dir . '/' . $file_name . '.' . $file_ext;
                            @unlink($file);
                        }
                    }
                }
                // close the directory
                closedir($handle);
            }
        }
    }
//.........这里部分代码省略.........
开发者ID:poweronio,项目名称:mbsite,代码行数:101,代码来源:bcp-core.php

示例13: record_cover_image

 function record_cover_image($params = array())
 {
     if (empty($params)) {
         return;
     }
     // avatar height - padding - 1/2 avatar height
     $avatar_offset = $params['height'] - 5 - round((int) bp_core_avatar_full_height() / 2);
     // header content offset + spacing
     $top_offset = bp_core_avatar_full_height() - 10;
     $left_offset = bp_core_avatar_full_width() + 20;
     $this->cover_image = $params['cover_image'];
 }
开发者ID:nikitansk,项目名称:devschool,代码行数:12,代码来源:bp-custom.php

示例14: do_action

			<?php 
/**
 * Fires before the activity post form.
 *
 * @since 1.2.0
 */
do_action('bp_before_activity_post_form');
?>

			<div id="whats-new-avatar">
				<a href="<?php 
echo bp_loggedin_user_domain();
?>
">
					<?php 
bp_loggedin_user_avatar('type=full&width=' . bp_core_avatar_full_width() . '&height=' . bp_core_avatar_full_height());
?>
				</a>
			</div>

			<p class="activity-greeting">
				<?php 
printf(__("Welcome back, %s", 'buddypress'), bp_get_user_firstname(bp_get_loggedin_user_fullname()));
?>
			</p>
			

			<?php 
wp_nonce_field('post_update', '_wpnonce_post_update');
?>
			<?php 
开发者ID:phasstw,项目名称:GaryClan,代码行数:31,代码来源:page-home-feed.php

示例15: tv_upload_file

function tv_upload_file()
{
    global $bp, $wpdb;
    if (!isset($bp->signup->step)) {
        $bp->signup = new stdClass();
    }
    if (!isset($bp->avatar_admin)) {
        $bp->avatar_admin = new stdClass();
    }
    $bp->signup->step = 'completed-confirmation';
    $next_user_id = get_last_id_auto_increment($wpdb->prefix . 'users');
    $bp->signup->avatar_dir = wp_hash($next_user_id);
    $bp->displayed_user->id = $next_user_id;
    //$bp->avatar_admin->image->url  = $_FILES['file']['name'];
    $avatar = tv_bp_core_avatar_handle_upload($_FILES, 'xprofile_avatar_upload_dir');
    if ($avatar) {
        $bp->avatar_admin->step = 'crop-image';
        ob_start();
        //tv_add_jquery_cropper();
        // Bail if no image was uploaded
        $image = apply_filters('bp_inline_cropper_image', getimagesize(bp_core_avatar_upload_path() . buddypress()->avatar_admin->image->dir));
        if (empty($image)) {
            //
            $full_height = bp_core_avatar_full_height();
        }
        $full_width = bp_core_avatar_full_width();
        // Calculate Aspect Ratio
        if (!empty($full_height) && $full_width != $full_height) {
            $aspect_ratio = $full_width / $full_height;
        } else {
            $aspect_ratio = 1;
        }
        // Default cropper coordinates
        $crop_left = round($image[0] / 4);
        $crop_top = round($image[1] / 4);
        $crop_right = $image[0] - $crop_left;
        $crop_bottom = $image[1] - $crop_top;
        $html = '<li class="image-wrap thumbnail" style="width: 100%">';
        //$html .= '<h5>'. _e( 'Crop Your New Avatar', 'buddypress' ).'</h5>';
        $html = '<img src="' . bp_get_avatar_to_crop() . '" id="avatar-to-crop" class="avatar" alt="Image to crop" />';
        $html .= '  <div id="avatar-crop-pane">';
        $html .= '      <img src="' . bp_get_avatar_to_crop() . '" id="avatar-crop-preview" class="avatar" alt="Crop Preview" />';
        $html .= '  </div>';
        $html .= '  <input type="button" name="avatar_crop_submit" id="avatar_crop_submit" value="Crop image" />';
        $html .= '  <img class="waiting" src="' . esc_url(admin_url('images/wpspin_light.gif')) . '" alt="" style="display:none" />';
        $html .= '<input type="hidden" name="image_src" id="image_src" value="' . bp_get_avatar_to_crop_src() . '" />';
        $html .= '<input type="hidden" name="id_user" id="id_user" value="' . $next_user_id . '" />';
        $html .= '<input type="hidden" id="x" name="x" />';
        $html .= '<input type="hidden" id="y" name="y" />';
        $html .= '<input type="hidden" id="w" name="w" />';
        $html .= '<input type="hidden" id="h" name="h" />';
        $html .= '<script type="text/javascript">';
        $html .= '
            jQuery("#avatar-to-crop").Jcrop({
                onChange: showPreview,
                onSelect: showPreview,
                onSelect: updateCoords,
                keySupport:false,
                aspectRatio: ' . $aspect_ratio . ',
                setSelect: [' . $crop_left . ', ' . $crop_top . ', ' . $crop_right . ', ' . $crop_bottom . ' ]
            });
            updateCoords({x:' . $crop_left . ', y: ' . $crop_top . ', w: ' . $crop_right . ', h: ' . $crop_bottom . '});

        function updateCoords(c) {
            jQuery("#x").val(c.x);
            jQuery("#y").val(c.y);
            jQuery("#w").val(c.w);
            jQuery("#h").val(c.h);
        }

        function showPreview(coords) {

            if ( parseInt(coords.w) > 0 ) {
                var fw = 150;
                var fh = 150;
                var rx = fw / coords.w;
                var ry = fh / coords.h;

                jQuery( "#avatar-crop-preview" ).css({
                    width: Math.round(rx * ' . $image[0] . ') + "px",
                    height: Math.round(ry * ' . $image[1] . ') + "px",
                    marginLeft: "-" + Math.round(rx * coords.x) + "px",
                    marginTop: "-" + Math.round(ry * coords.y) + "px"
                });
            }
        }

        ';
        $html .= '</script>';
        $html .= '
        <style type="text/css">
        .jcrop-holder { float: left; margin: 0 20px 20px 0; text-align: left; }
        #avatar-crop-pane { width: 150px; height: 150px; overflow: hidden; }
        #avatar-crop-submit { margin: 20px 0; }
        .jcrop-holder img,
        #avatar-crop-pane img,
        #avatar-upload-form img,
        #create-group-form img,
        #group-settings-form img { border: none !important; max-width: none !important; }
    </style>    ';
//.........这里部分代码省略.........
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:101,代码来源:bp-signup-avatar.php


注:本文中的bp_core_avatar_full_width函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。