WC_Regenerate_Images::get_full_size_image_dimensions
Get full size image dimensions.
Method of the class: WC_Regenerate_Images{}
No Hooks.
Returns
Array. Width and height. Empty array if the dimensions cannot be found.
Usage
$result = WC_Regenerate_Images::get_full_size_image_dimensions( $attachment_id );
- $attachment_id(int) (required)
- Attachment ID of image.
WC_Regenerate_Images::get_full_size_image_dimensions() WC Regenerate Images::get full size image dimensions code WC 10.7.0
private static function get_full_size_image_dimensions( $attachment_id ) {
$imagedata = wp_get_attachment_metadata( $attachment_id );
if ( ! is_array( $imagedata ) ) {
return array();
}
if ( ! isset( $imagedata['file'] ) && isset( $imagedata['sizes']['full'] ) ) {
$imagedata['height'] = $imagedata['sizes']['full']['height'];
$imagedata['width'] = $imagedata['sizes']['full']['width'];
}
// The result of the earlier wp_get_attachment_metadata call is filterable, so we may not have height or
// width data at this point.
if ( ! isset( $imagedata['height'] ) || ! isset( $imagedata['width'] ) ) {
return array();
}
return array(
'width' => $imagedata['width'],
'height' => $imagedata['height'],
);
}