You can always use the wp_get_additional_image_sizes()
function to retrieve an image "size" (i.e. width, height, and the 'crop' option), like this:
$image_sizes = wp_get_additional_image_sizes();
if ( isset( $image_sizes['slide_image'] ) ) {
$size = $image_sizes['slide_image'];
var_dump( $size ); // Demo
echo $size['width']; // Demo
}
UPDATE
In reply to your comment,
i want to get the current post featured image width and height..how to
do it
Use the wp_get_attachment_image_src()
function:
The returned array contains four values: the URL of the attachment
image src, the width of the image file, the height of the image file,
and a boolean representing whether the returned array describes an
intermediate (generated) image size or the original, full-sized
upload.
— More on https://developer.wordpress.org/reference/functions/wp_get_additional_image_sizes/
But anyway, try this function
:
// See https://wordpress.stackexchange.com/q/301465/137402
function my_wpse301465( $image_size, $post = null ) {
$post_thumbnail_id = get_post_thumbnail_id( $post );
$info = $post_thumbnail_id ?
wp_get_attachment_image_src( $post_thumbnail_id, $image_size ) : null;
if ( $info ) {
$sizes = wp_get_additional_image_sizes();
$size = isset( $sizes[ $image_size ] ) ? $sizes[ $image_size ] : null;
return $size ? (
$info[1] < $size['width'] ||
$info[2] < $size['height']
) : false;
}
}
And here's how you could use it:
// Or pass a post ID as in my_wpse301465( 'slide_image', 123 ).
if ( my_wpse301465( 'slide_image' ) ) {
echo 'Hide featured image.';
} else {
echo 'Show featured image.';
}
add_post_meta($post_id, $meta_key, $meta_value, $unique);
for updateupdate_post_meta($post_id, $meta_key, $meta_value, $prev_value);