Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
WC_Regenerate_Images::get_image( string $fullsizepath, int $thumbnail_width, int $thumbnail_height, bool $crop )
Generate the thumbnail filename and dimensions for a given file.
Description Description
Parameters Parameters
- $fullsizepath
-
(Required) Path to full size image.
- $thumbnail_width
-
(Required) The width of the thumbnail.
- $thumbnail_height
-
(Required) The height of the thumbnail.
- $crop
-
(Required) Whether to crop or not.
Return Return
(array|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.
Source Source
File: includes/class-wc-regenerate-images.php
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, ); }