New image size 'medium_large' not generated on upload
-
I’m currently refactoring my Bootstrap based theme for the new responsive image attributes. It’s working fine for all my standard sizes (thumbnail, medium, large, post_thumbnail). From the (rather poor) documentation of the new features I’ve learned, that there should be another image size ‘medium_large’, which is auto-generated on new uploads, but is not available thru the editor. Bon. So I guess, that it could be used as a smaller version of another image size in the ‘sizes’ and ‘srcset’ settings. To enforce a reasonable size, I use this code in my theme:
/* * Enforce images sizes matching large device Bootstrap cols on theme switch * */ add_action( 'switch_theme', 'bootstrapped_enforce_image_size_options' ); function bootstrapped_enforce_image_size_options() { update_option( 'thumbnail_size_w', 155 ); update_option( 'thumbnail_size_h', 0 ); update_option( 'thumbnail_crop', 0 ); update_option( 'medium_size_w', 220 ); update_option( 'medium_size_h', 0 ); update_option( 'medium_large_size_w', 460 ); update_option( 'medium_large_size_h', 0 ); update_option( 'large_size_w', 350 ); update_option( 'large_size_h', 0 ); } /* * Revert any possible administrator overrides of media settings */ add_filter( 'pre_update_option_thumbnail_size_w', 'bootstrapped_filter_thumbnail_size_w' ); function bootstrapped_filter_thumbnail_size_w( $newvalue ) { return 155; } add_filter( 'pre_update_option_thumbnail_size_h', 'bootstrapped_filter_thumbnail_size_h' ); function bootstrapped_filter_thumbnail_size_h( $newvalue ) { return 9999; } add_filter( 'pre_update_option_thumbnail_crop', 'bootstrapped_filter_thumbnail_crop' ); function bootstrapped_filter_thumbnail_crop( $newvalue ) { return 0; } add_filter( 'pre_update_option_medium_size_w', 'bootstrapped_filter_medium_size_w' ); function bootstrapped_filter_medium_size_w( $newvalue ) { return 220; } add_filter( 'pre_update_option_medium_size_h', 'bootstrapped_filter_medium_size_h' ); function bootstrapped_filter_medium_size_h( $newvalue ) { return 9999; } add_filter( 'pre_update_option_large_size_w', 'bootstrapped_filter_large_size_w' ); function bootstrapped_filter_large_size_w( $newvalue ) { return 350; } add_filter( 'pre_update_option_large_size_h', 'bootstrapped_filter_large_size_h' ); function bootstrapped_filter_large_size_h( $newvalue ) { return 9999; }
I’m not quite sure, if this code is OK (xxx_size_h = 0 in first codeblock ??, 9999 in second ??)
When I upload a new image, all sizes are generated fine – except medium_large. Neither as factory default size (768px x 9999), nor as my custom size (460px x 9999). The ‘srcset’, where I would expect ‘medium_large’ as well, shows only the other, working, image sizes and the original image.
Can anyone share a light on ‘medium_large’?
Edit: Forgot to mention that I switched the theme before the image upload.
var_dump( get_intermediate_image_sizes()
array(5) { [0]=> string(9) "thumbnail" [1]=> string(6) "medium" [2]=> string(12) "medium_large" [3]=> string(5) "large" [4]=> string(14) "post-thumbnail" }
So it’s “kind of there”
- The topic ‘New image size 'medium_large' not generated on upload’ is closed to new replies.