本文整理汇总了PHP中bp_core_avatar_thumb_height函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_core_avatar_thumb_height函数的具体用法?PHP bp_core_avatar_thumb_height怎么用?PHP bp_core_avatar_thumb_height使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_core_avatar_thumb_height函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_core_fetch_avatar
//.........这里部分代码省略.........
$html_title = ' title="' . esc_attr($params['title']) . '"';
}
// Extra attributes
$extra_attr = !empty($args['extra_attr']) ? ' ' . $args['extra_attr'] : '';
// Set CSS ID and create html string.
$html_css_id = '';
/**
* Filters the ID attribute to be applied to avatar.
*
* @since 2.2.0
*
* @param string $value ID to be applied to avatar.
* @param string $value ID of avatar item being requested.
* @param string $value Avatar type being requested.
* @param array $params Array of parameters for the request.
*/
$params['css_id'] = apply_filters('bp_core_css_id', $params['css_id'], $params['item_id'], $params['object'], $params);
if (!empty($params['css_id'])) {
$html_css_id = ' id="' . esc_attr($params['css_id']) . '"';
}
// Set image width
if (false !== $params['width']) {
// Width has been specified. No modification necessary.
} elseif ('thumb' == $params['type']) {
$params['width'] = bp_core_avatar_thumb_width();
} else {
$params['width'] = bp_core_avatar_full_width();
}
$html_width = ' width="' . $params['width'] . '"';
// Set image height
if (false !== $params['height']) {
// Height has been specified. No modification necessary.
} elseif ('thumb' == $params['type']) {
$params['height'] = bp_core_avatar_thumb_height();
} else {
$params['height'] = bp_core_avatar_full_height();
}
$html_height = ' height="' . $params['height'] . '"';
/**
* Filters the classes to be applied to the avatar.
*
* @since 1.6.0
*
* @param array|string $value Class(es) to be applied to the avatar.
* @param string $value ID of the avatar item being requested.
* @param string $value Avatar type being requested.
* @param array $params Array of parameters for the request.
*/
$params['class'] = apply_filters('bp_core_avatar_class', $params['class'], $params['item_id'], $params['object'], $params);
// Use an alias to leave the param unchanged
$avatar_classes = $params['class'];
if (!is_array($avatar_classes)) {
$avatar_classes = explode(' ', $avatar_classes);
}
// merge classes
$avatar_classes = array_merge($avatar_classes, array($params['object'] . '-' . $params['item_id'] . '-avatar', 'avatar-' . $params['width']));
// Sanitize each class
$avatar_classes = array_map('sanitize_html_class', $avatar_classes);
// populate the class attribute
$html_class = ' class="' . join(' ', $avatar_classes) . ' photo"';
// Set img URL and DIR based on prepopulated constants
$avatar_loc = new stdClass();
$avatar_loc->path = trailingslashit(bp_core_avatar_upload_path());
$avatar_loc->url = trailingslashit(bp_core_avatar_url());
$avatar_loc->dir = trailingslashit($params['avatar_dir']);
/**
示例2: bp_activity_post_form_action
<form action="<?php
bp_activity_post_form_action();
?>
" method="post" id="whats-new-form" name="whats-new-form" role="complementary">
<?php
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('width=' . bp_core_avatar_thumb_width() . '&height=' . bp_core_avatar_thumb_height());
?>
</a>
</div>
<h5><?php
if (bp_is_group()) {
printf(__("What's new in %s, %s?", 'buddypress'), bp_get_group_name(), bp_get_user_firstname());
} else {
printf(__("What's new, %s?", 'buddypress'), bp_get_user_firstname());
}
?>
</h5>
<div id="whats-new-content">
<div id="whats-new-textarea">
示例3: 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 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 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
$existing_avatar = bp_core_fetch_avatar(array('object' => $object, 'item_id' => $item_id, 'html' => false));
if (!empty($existing_avatar)) {
// 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) {
bp_core_delete_existing_avatar(array('object' => $object, 'item_id' => $item_id, '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;
}
示例4: 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;
}
示例5: widget
function widget($args, $instance)
{
global $bp;
extract($args);
echo $before_widget;
echo $before_title . $widget_name . $after_title;
?>
<?php
if (bp_has_links('type=popular&per_page=' . $instance['max_links'] . '&max=' . $instance['max_links'])) {
?>
<div class="item-options" id="links-list-options">
<span class="ajax-loader" id="ajax-loader-links"></span>
<a href="<?php
echo site_url() . '/' . bp_links_root_slug();
?>
" id="newest-links"><?php
_e("Newest", 'buddypress');
?>
</a> |
<?php
if (bp_links_is_voting_enabled()) {
?>
<a href="<?php
echo site_url() . '/' . bp_links_root_slug();
?>
" id="most-votes"><?php
_e("Votes", 'buddypress-links');
?>
</a> |
<a href="<?php
echo site_url() . '/' . bp_links_root_slug();
?>
" id="high-votes"><?php
_e("Rating", 'buddypress-links');
?>
</a> |
<a href="<?php
echo site_url() . '/' . bp_links_root_slug();
?>
" id="popular-links" class="selected"><?php
_e("Popular", 'buddypress');
?>
</a>
<?php
} else {
?>
<a href="<?php
echo site_url() . '/' . bp_links_root_slug();
?>
" id="active-links"><?php
_e("Active", 'buddypress');
?>
</a>
<?php
}
?>
</div>
<ul id="links-list" class="item-list">
<?php
while (bp_links()) {
bp_the_link();
?>
<li>
<div class="item-avatar">
<a href="<?php
bp_link_permalink();
?>
"><?php
bp_link_avatar(array('width' => bp_core_avatar_thumb_width(), 'height' => bp_core_avatar_thumb_height()));
?>
</a>
</div>
<div class="item">
<div class="item-title"><a href="<?php
bp_link_permalink();
?>
" title="<?php
bp_link_name();
?>
"><?php
bp_link_name();
?>
</a></div>
<?php
if (bp_links_is_voting_enabled()) {
?>
<div class="item-meta"><span class="activity"><?php
printf(__('%+d rating', 'buddypress-links'), bp_get_link_vote_total());
?>
</span></div>
<?php
}
?>
</div>
</li>
<?php
//.........这里部分代码省略.........
示例6: 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;
}
示例7: do_action
<?php
do_action('mpp_after_lightbox_media', $media);
?>
</div>
<div class="mpp-lightbox-activity-container">
<div class="mpp-lightbox-media-uploader-meta mpp-clearfix">
<div class="mpp-lightbox-media-uploader-avatar">
<a href="<?php
echo bp_core_get_user_domain(mpp_get_media_creator_id());
?>
">
<?php
echo bp_core_fetch_avatar(array('item_id' => mpp_get_media_creator_id(), 'object' => 'members', 'width' => bp_core_avatar_thumb_width(), 'height' => bp_core_avatar_thumb_height()));
?>
</a>
</div>
<div class="mpp-lightbox-uploader-upload-details">
<div class="mpp-lightbox-uploader-link">
<?php
echo bp_core_get_userlink(mpp_get_media_creator_id());
?>
</div>
</div>
</div><!--end of the top row -->
<div class="mpp-item-description mpp-media-description mpp-lightbox-media-description mpp-clearfix">
<?php
mpp_media_description();
?>
示例8: do_action
<?php
do_action('mpp_after_lightbox_media', $media);
?>
</div>
<div class="mpp-lightbox-activity-container">
<div class="mpp-lightbox-media-uploader-meta mpp-clearfix">
<div class="mpp-lightbox-media-uploader-avatar">
<a href="<?php
echo bp_core_get_user_domain(mpp_get_media_creator_id());
?>
">
<?php
echo bp_core_fetch_avatar(array('object' => 'members', 'width' => bp_core_avatar_thumb_width(), 'height' => bp_core_avatar_thumb_height()));
?>
</a>
</div>
<div class="mpp-lightbox-uploader-upload-details">
<div class="mpp-lightbox-uploader-link">
<?php
echo bp_core_get_userlink(mpp_get_media_creator_id());
?>
</div>
</div>
</div><!--end of the top row -->
<div class="mpp-item-description mpp-media-description mpp-lightbox-media-description mpp-clearfix">
<?php
mpp_media_description();
?>
示例9: do_action
<div class="inner-sidebar <?php
do_action('wf_class_inner_sidebar');
?>
inner-sidebar-mobile">
<a id="close-buddypress-mobile-sidebar" class="close-panel-button" href="#">
<i class="fa fa-times-circle"></i> Close menu
</a>
<?php
if (bp_is_user()) {
?>
<div id="user-sidebar-menu" class="widget">
<?php
bp_displayed_user_avatar('width=' . bp_core_avatar_thumb_width() . '&height=' . bp_core_avatar_thumb_height());
?>
<?php
$userLink = bp_get_displayed_user_link();
?>
<strong><?php
echo bp_core_get_user_displayname(bp_displayed_user_id());
?>
</strong>
<br>
</div>
<?php
}
?>
<?php