$currheight ) { $adjusted_width =$currwidth / $hm; $half_width = $adjusted_width / 2; $int_width = $half_width - $w_height; imagecopyresampled($dimg ,$simg ,-$int_width,0,0,0, $adjusted_width, $nheight, $currwidth , $currheight ); } elseif(($currwidth < $currheight ) || ($currwidth == $currheight )) { $adjusted_height = $currheight / $wm; $half_height = $adjusted_height / 2; $int_height = $half_height - $h_height; imagecopyresampled($dimg , $simg ,0,-$int_height,0,0, $nwidth, $adjusted_height, $currwidth , $currheight ); }else { imagecopyresampled($dimg , $simg ,0,0,0,0, $nwidth, $nheight, $currwidth , $currheight ); } } else { if ($currheight > $currwidth) { // If Height Is Greater Than Width $zoom = $nheight / $currheight; // Length Ratio For Width $newheight = $nheight; // Height Is Equal To Max Height $newwidth = round($currwidth * $zoom); // Creates The New Width } else { // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height) $zoom = $nwidth / $currwidth; // Length Ratio For Height $newwidth = $nwidth; // Width Is Equal To Max Width $newheight = round($currheight * $zoom); // Creates The New Height if($newheight > $nheight) { $zoom = $nheight / $currheight; $newheight = $nheight; $newwidth = round($currwidth * $zoom); } } $dimg = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight); } if ($file_extension == "jpg" || $file_extension == "jpeg" || $file_extension == "gif" ) { imagejpeg($dimg, $save_path. '/' . $newName,$quality); // Saving The Image } elseif($file_extension == "png") { imagepng($dimg, $save_path. '/' . $newName); // Saving The Image } imagedestroy($simg); // Destroying The Temporary Image imagedestroy($dimg); // Destroying The Other Temporary Image // Set correct file permissions $stat = stat( dirname( $save_path. '/' . $newName )); $perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits @ chmod( $save_path. '/' . $newName, $perms ); return $newName; } } function bmb_theme_author_photo_updates() { // See if the user has posted us some information if (!empty($_GET['reset'])) { if ( check_admin_referer('bmb_profile_photo-reset') ) { $opt_val = get_option('bmb_author_profile'); $file = ABSPATH.'wp-content/uploads/'.$opt_val; if (file_exists($file)) unlink($file); delete_option('bmb_author_profile'); wp_redirect(admin_url('themes.php?page=bmb-author-photo&reseted=true')); } } elseif ($_POST) { if ( check_admin_referer('bmb-author-profile-upload-update') ) { if ( !empty($_FILES) && isset($_POST['submit-photo']) ) { $overrides = array('test_form' => false); $file = wp_handle_upload($_FILES['import'], $overrides); if ( isset($file['error']) ) wp_die( $file['error'] ); $file = $file['file']; $upload_dir = wp_upload_dir(); $profile_photo = bmb_resize_images($file, '265','300',$upload_dir['basedir']); $opt_val = get_option('bmb_author_profile'); if ($opt_val) { $current_file = ABSPATH.'wp-content/uploads/'.$opt_val; if (file_exists($current_file)) unlink($current_file); } update_option('bmb_author_profile', $profile_photo); unlink($file); } if (isset($_POST['custom_url'])) { $custom_url = $_POST['custom_url']; update_option('bmb_author_profile_url', $custom_url); } // wp_redirect(admin_url('themes.php?page=bmb-author-photo&updated=true')); } } } function bmb_theme_author_photo_settings() { //must check that the user has the required capability if (!current_user_can('manage_options')) { wp_die( __('You do not have sufficient permissions to access this page.') ); } // Read in existing option value from database $opt_val = get_option('bmb_author_profile'); $custom_url = get_option('bmb_author_profile_url'); ?>
Visit your site to see how it looks.' ), home_url( '/' ) ); ?>