Home Forums Bug Reports About code example in image documentation


About code example in image documentation

  • A quick question about the image documentation:

    Under the header Basic display (ID), shouldn’t the line

    echo wp_get_attachment_image( $image, $size );

    rather be

    echo wp_get_attachment_image( $image['ID'], $size );


  • That example would be used if you change set the return value of the field to ID.

    This example shows how to display the selected image when using the ID return type. This return type allows us to efficiently load only the necessary image data.

    If you’re returning an image object there’s really no need to use the wp_get_attachment_image() function because the returned array contains all of the image information for all sizes and ACF runs this function in order to build the value returned by the field. You can see wht’s returned in the image array by following

  • Ah! I missed that part about setting the return type, that explains the code in the example. Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘About code example in image documentation’ is closed to new replies.