芝麻web文件管理V1.00
编辑当前文件:/home4/randall/public_html/sl/wp-content/plugins/essential-grid/includes/aq_resizer.class.php
resize($width, $height, $crop))) return false; $resized_file = $editor->save(); if (!is_wp_error($resized_file)) { $resized_rel_path = str_replace($upload_dir, '', $resized_file['path']); $img_url = $upload_url . $resized_rel_path; } else { return false; } } } // Okay, leave the ship. if (true === $upscale) remove_filter('image_resize_dimensions', array($this, 'aq_upscale')); // Return the output. if ($single) { // str return. $image = $img_url; } else { // array return. $image = array( 0 => $img_url, 1 => $dst_w, 2 => $dst_h ); } return $image; } /** * Callback to overwrite WP computing of thumbnail measures */ function aq_upscale($default, $orig_w, $orig_h, $dest_w, $dest_h, $crop) { if (!$crop) return null; // Let the wordpress default function handle this. // Here is the point we allow to use larger image size than the original one. $aspect_ratio = $orig_w / $orig_h; $new_w = $dest_w; $new_h = $dest_h; if (!$new_w) { $new_w = intval($new_h * $aspect_ratio); } if (!$new_h) { $new_h = intval($new_w / $aspect_ratio); } $size_ratio = max($new_w / $orig_w, $new_h / $orig_h); $crop_w = round($new_w / $size_ratio); $crop_h = round($new_h / $size_ratio); $s_x = floor(($orig_w - $crop_w) / 2); $s_y = floor(($orig_h - $crop_h) / 2); return array(0, 0, (int)$s_x, (int)$s_y, (int)$new_w, (int)$new_h, (int)$crop_w, (int)$crop_h); } } } if (!function_exists('esg_aq_resize')) { /** * This is just a tiny wrapper function for the class above so that there is no * need to change any code in your own WP themes. Usage is still the same :) */ function esg_aq_resize($url, $width = null, $height = null, $crop = null, $single = true, $upscale = false) { $aq_resize = Essential_Grid_Aqua_Resize::getInstance(); $img = $aq_resize->process($url, $width, $height, $crop, $single, $upscale); if ($single) { return ($img == '') ? $url : $img; } else { return (empty($img)) ? $url : $img; } } }