One of my themes didn’t have a Genesis Featured Image.
Actually it did, but it didn’t have it as an named additional image. And this was a problem because I like to have the featured image size listed in my featured image box, as I explained how to do in my post about how to do this in Featured Image Size. That theme was using the ‘medium’ size for featured images, which meant by code made the box look like this:
This is because I had no $_wp_additional_image_sizes
, and that’s what I meant when I said there was no named additional image size. So I had to change up my calculation and check first if the name of the image size was one of the defaults, ‘thumbnail’, ‘medium’, or ‘large’, and size off that and then check the other options.
Which gives me this:
// What is my image size? add_filter( 'admin_post_thumbnail_html', 'helf_admin_post_thumbnail_html' ); function helf_admin_post_thumbnail_html( $content ) { // Define what the name of our featured image size is $genesis = get_option('genesis-settings'); $genesis_image_size = $genesis['image_size']; // Get featured image size global $_wp_additional_image_sizes; if ( in_array( $genesis_image_size, array( 'thumbnail', 'medium', 'large' ) ) ) { $size_width = get_option( $genesis_image_size . '_size_w' ); $size_height = get_option( $genesis_image_size . '_size_h' ); } elseif ( isset( $_wp_additional_image_sizes[ $genesis_image_size ] ) ) { $size_width = $_wp_additional_image_sizes[$genesis_image_size]['width']; $size_height = $_wp_additional_image_sizes[$genesis_image_size]['height']; } $my_featured_image = $size_width.'x'.$size_height; // Apply $imagesize = '<p>Image Size: ' . $my_featured_image . 'px</p>'; $content = $imagesize . $content; return $content; }
Right below the global check, I do an if to scan the array and grab the sizes based on that. It’s exceptionally simple, and the major change was moving it to set variables and then setting based on those outside of the if/else check. But it works perfectly on both my sites with regular sizes and the fancy sizes.
I still don’t have a check to see if the theme is Genesis or not, but this multisite is 100% Genesis for all sites, so it’s not an issue for me. If anyone has a way to check “Is this active theme on this site Genesis or a child,” please share. The world will thank you.