WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I retrieve the post thumbnail (featured image) as an array?
Using get_post_thumbnail() I noticed in the WP documentation that there is a third parameter from, which I understand, one would be able to set it to return the values as an array instead of a string, but I can't figure out how.
The reason I want to return the image as an array is to exclude unnecessary attributes in the output such as 'wp-post-image' etc.

Problem solved:

$image = wp_get_attachment_image_src( get_post_thumbnail_id(), $size);
share|improve this question
Staffan, please, add the solution as an Answer and mark this topic as solved. – brasofilo Nov 28 '12 at 11:30
I have added the solution :) – Staffan Estberg Nov 30 '12 at 9:44

The solution is to use wp_get_attachment_image_src. As per the Codex:

$attachment_id = 8;
$size = 'full';

// returns an array
$image_attributes = wp_get_attachment_image_src( $attachment_id, $size ); 

Although the return is said to be:

[0] => url
[1] => width
[2] => height

There is a fourth element that indicates if it is the full image (false) or an intermediate image (true):

[3] => is_intermediate
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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