WC_REST_Setting_Options_V2_Controller::cast_image_width
For image_width, Crop can return "0" instead of false -- so we want to make sure we return these consistently the same we accept them.
Method of the class: WC_REST_Setting_Options_V2_Controller{}
No Hooks.
Returns
Array.
Usage
$WC_REST_Setting_Options_V2_Controller = new WC_REST_Setting_Options_V2_Controller(); $WC_REST_Setting_Options_V2_Controller->cast_image_width( $setting );
- $setting(array) (required)
- Settings.
Changelog
| Since 3.0.0 | Introduced. |
WC_REST_Setting_Options_V2_Controller::cast_image_width() WC REST Setting Options V2 Controller::cast image width code WC 10.8.1
public function cast_image_width( $setting ) {
foreach ( array( 'default', 'value' ) as $key ) {
if ( isset( $setting[ $key ] ) ) {
$setting[ $key ]['width'] = intval( $setting[ $key ]['width'] );
$setting[ $key ]['height'] = intval( $setting[ $key ]['height'] );
$setting[ $key ]['crop'] = (bool) $setting[ $key ]['crop'];
}
}
return $setting;
}