WC_Regenerate_Images::get_image() private WC 1.0
Generate the thumbnail filename and dimensions for a given file.
{} Это метод класса: WC_Regenerate_Images{}
Хуков нет.
Возвращает
Массив/false. An array of the filename, thumbnail width, and thumbnail height, or false on failure to resize such as the thumbnail being larger than the fullsize image.
Использование
$result = WC_Regenerate_Images::get_image( $fullsizepath, $thumbnail_width, $thumbnail_height, $crop );
- $fullsizepath(строка) (обязательный)
- Path to full size image.
- $thumbnail_width(число) (обязательный)
- The width of the thumbnail.
- $thumbnail_height(число) (обязательный)
- The height of the thumbnail.
- $crop(true/false) (обязательный)
- Whether to crop or not.
Код WC_Regenerate_Images::get_image() WC Regenerate Images::get image WC 5.0.0
private static function get_image( $fullsizepath, $thumbnail_width, $thumbnail_height, $crop ) {
list( $fullsize_width, $fullsize_height ) = getimagesize( $fullsizepath );
$dimensions = image_resize_dimensions( $fullsize_width, $fullsize_height, $thumbnail_width, $thumbnail_height, $crop );
$editor = wp_get_image_editor( $fullsizepath );
if ( is_wp_error( $editor ) ) {
return false;
}
if ( ! $dimensions || ! is_array( $dimensions ) ) {
return false;
}
list( , , , , $dst_w, $dst_h ) = $dimensions;
$suffix = "{$dst_w}x{$dst_h}";
$file_ext = strtolower( pathinfo( $fullsizepath, PATHINFO_EXTENSION ) );
return array(
'filename' => $editor->generate_filename( $suffix, null, $file_ext ),
'width' => $dst_w,
'height' => $dst_h,
);
}