wp_get_attachment_image_src() and custom sizes

As said in this page, wp_get_attachment_image_src()only accepts built-in sizes such as thumbnail, medium, large or full.

How do you get the same return value with custom sizes you add with add_image_sizes() ?

Solutions Collecting From Web of "wp_get_attachment_image_src() and custom sizes"

You are misreading the Codex. wp_get_attachment_image_src() works just fine with custom image sizes.

Proof of concept:

// copied from the Codex
// https://codex.wordpress.org/Function_Reference/add_image_size
if ( function_exists( 'add_image_size' ) ) { 
    add_image_size( 'category-thumb', 300, 9999 ); //300 pixels wide (and unlimited height)
    add_image_size( 'homepage-thumb', 220, 180, true ); //(cropped)

Add an image to the Library, then…

$image_attributes = wp_get_attachment_image_src( 28, 'category-thumb' ); 

You will notice that the image returned is (an appromixation of) 300×9999– that is 300 wide by whatever height scales correctly.