What function can I use in a plugin to get the dimensions of every image size (in an array preferably) that is defined in a child theme?
Just for clarification I am not asking how to create a new image size.
What function can I use in a plugin to get the dimensions of every image size (in an array preferably) that is defined in a child theme?
Just for clarification I am not asking how to create a new image size.
You must be logged in to post a comment.
Found it here. The answer is:
WordPress core doesn’t have a native method for getting intermediate image sizes (i.e. width and height), but the following helper function will get all registered image sizes along with their dimensions:
Which will output results similar to:
If you only need the names of all image sizes, you can use get_intermediate_image_sizes:
Since WP 5.3 it is enough to use this function:
Documentation: https://developer.wordpress.org/reference/functions/wp_get_registered_image_subsizes/
If the other answer did not work, use this code, so it will run after WordPress is initialized.
Since WP 4.7 you can use wp_get_additional_image_sizes() to get additional image sizes registered (excluding the default image sizes added by WP).
Since WP 5.3 you can use wp_get_registered_image_subsizes() to get all the image sizes registered.
Use the following functions: