I am trying to get both full and thumbnail images from post with wp_get_attachment_image_url:

wp_get_attachment_image_url( get_the_ID(), array('thumbnail, full'));

I know that by default size is thumbnail and I read from documentation that I can pass and array of sizes, but with above example, I am getting an error:

A non-numeric value encountered

The documentation is not clear about how to pass an array of sizes as parameter.

1 Answer 1


You’re almost correct.

You really can pass an array as size parameter for that function, but...

$size (string|array) (Optional) Image size to retrieve. Accepts any valid image size, or an array of width and height values in pixels (in that order). Default value: 'thumbnail'

So you can’t use it in the way you wanted to...

You have to pass name of the size or an array that will define the size in pixels (width and height).

You can get only one size with one call of that function (as it returns only one value - url of image in given size).

But that’s not a problem, just call it twice:

$thumb_url = wp_get_attachment_image_url( get_the_ID(), 'thumbnail');
$full_url = wp_get_attachment_image_url( get_the_ID(), 'full');
  • Thanks, I just want to prevent this twice :). I will use that for now and may be custom query, later
    – gdfgdfg
    Commented Jan 14, 2019 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.