Changeset 6600 for trunk/bp-core/bp-core-cssjs.php
- Timestamp:
- 12/10/2012 12:52:16 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/bp-core/bp-core-cssjs.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-cssjs.php
r6597 r6600 1 1 <?php 2 2 3 // Exit if accessed directly 3 4 if ( !defined( 'ABSPATH' ) ) exit; … … 26 27 }); 27 28 </script> 29 28 30 <?php 29 31 } … … 39 41 */ 40 42 function bp_core_add_jquery_cropper() { 43 wp_enqueue_style( 'jcrop' ); 41 44 wp_enqueue_script( 'jcrop', array( 'jquery' ) ); 42 45 add_action( 'wp_head', 'bp_core_add_cropper_inline_js' ); … … 52 55 */ 53 56 function bp_core_add_cropper_inline_js() { 54 global $bp;55 57 56 $image = apply_filters( 'bp_inline_cropper_image', getimagesize( bp_core_avatar_upload_path() . $bp->avatar_admin->image->dir ) ); 57 $aspect_ratio = 1; 58 // Bail if no image was uploaded 59 $image = apply_filters( 'bp_inline_cropper_image', getimagesize( bp_core_avatar_upload_path() . buddypress()->avatar_admin->image->dir ) ); 60 if ( empty( $image ) ) 61 return; 58 62 63 // 59 64 $full_height = bp_core_avatar_full_height(); 60 65 $full_width = bp_core_avatar_full_width(); 61 66 62 67 // Calculate Aspect Ratio 63 if ( $full_height && ( $full_width != $full_height ) )68 if ( !empty( $full_height ) && ( $full_width != $full_height ) ) { 64 69 $aspect_ratio = $full_width / $full_height; 70 } else { 71 $aspect_ratio = 1; 72 } 65 73 66 $width = $image[0] / 2; 67 $height = $image[1] / 2; 68 ?> 74 // Default cropper coordinates 75 $crop_left = $image[0] / 4; 76 $crop_top = $image[1] / 4; 77 $crop_right = $image[0] - $crop_left; 78 $crop_bottom = $image[1] - $crop_top; ?> 69 79 70 80 <script type="text/javascript"> … … 74 84 onSelect: showPreview, 75 85 onSelect: updateCoords, 76 aspectRatio: <?php echo $aspect_ratio ?>,77 setSelect: [ 50, 50, <?php echo $width ?>, <?php echo $height?> ]86 aspectRatio: <?php echo $aspect_ratio; ?>, 87 setSelect: [ <?php echo $crop_left; ?>, <?php echo $crop_top; ?>, <?php echo $crop_right; ?>, <?php echo $crop_bottom; ?> ] 78 88 }); 79 updateCoords({x: 50, y: 50, w: <?php echo $width ?>, h: <?php echo $height?>});89 updateCoords({x: <?php echo $crop_left; ?>, y: <?php echo $crop_top; ?>, w: <?php echo $crop_right; ?>, h: <?php echo $crop_bottom; ?>}); 80 90 }); 81 91 … … 89 99 function showPreview(coords) { 90 100 if ( parseInt(coords.w) > 0 ) { 91 var rx = <?php echo $full_width; ?> / coords.w; 92 var ry = <?php echo $full_height; ?> / coords.h; 101 var fw = <?php echo $full_width; ?>; 102 var fh = <?php echo $full_height; ?>; 103 var rx = fw / coords.w; 104 var ry = fh / coords.h; 93 105 94 jQuery('#avatar-crop-preview').css({ 95 <?php if ( $image ) : ?> 106 jQuery( '#avatar-crop-preview' ).css({ 96 107 width: Math.round(rx * <?php echo $image[0]; ?>) + 'px', 97 108 height: Math.round(ry * <?php echo $image[1]; ?>) + 'px', 98 <?php endif; ?>99 109 marginLeft: '-' + Math.round(rx * coords.x) + 'px', 100 110 marginTop: '-' + Math.round(ry * coords.y) + 'px' … … 119 129 <style type="text/css"> 120 130 .jcrop-holder { float: left; margin: 0 20px 20px 0; text-align: left; } 121 .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'); }122 .jcrop-vline { height: 100%; width: 1px !important; }123 .jcrop-hline { width: 100%; height: 1px !important; }124 .jcrop-handle { font-size: 1px; width: 7px !important; height: 7px !important; border: 1px #eee solid; background-color: #333; *width: 9px; *height: 9px; }125 .jcrop-tracker { width: 100%; height: 100%; }126 .custom .jcrop-vline, .custom .jcrop-hline { background: yellow; }127 .custom .jcrop-handle { border-color: black; background-color: #C7BB00; -moz-border-radius: 3px; -webkit-border-radius: 3px; }128 131 #avatar-crop-pane { width: <?php echo bp_core_avatar_full_width() ?>px; height: <?php echo bp_core_avatar_full_height() ?>px; overflow: hidden; } 129 132 #avatar-crop-submit { margin: 20px 0; } 130 #avatar-upload-form img, #create-group-form img, #group-settings-form img { border: none !important; } 133 #avatar-upload-form img, 134 #create-group-form img, 135 #group-settings-form img { border: none !important; max-width: none !important; } 131 136 </style> 132 137
Note: See TracChangeset
for help on using the changeset viewer.