ControlledChaos of Controlled Chaos Design
8/9/2016 - 6:45 PM

Add custom image sizes to "Insert Media" in the content editor and add custom class to the <img> tag.

Add custom image sizes to "Insert Media" in the content editor and add custom class to the tag.

<?php
function ccd_insert_custom_image_sizes( $sizes ) {
	global $_wp_additional_image_sizes;
	if ( empty($_wp_additional_image_sizes) )
	return $sizes;

	foreach ( $_wp_additional_image_sizes as $id => $data ) {
	if ( !isset($sizes[$id]) )
	$sizes[$id] = ucfirst( str_replace( '-', ' ', $id ) );
	}

return $sizes;
}
add_filter( 'image_size_names_choose', 'ccd_insert_custom_image_sizes' );
?>

Insert Custom Image Sizes with Classes

WordPress Snippet