I am using custom metabox for a page in my new project, I am using it for uploading image, and attaching it to the page. It's working fine, I can select image or upload the image using WordPress' native uploader, and attach it. The issue is that I am getting the large size image only.

What happens is I have to resize it by specifying its width and height. Is there any way to get the other sizes of the uploaded or selected images via WordPress native uploader.

I know I can get the thumbnails by using wp_get_attachment_image_src function, but in order to work with this function I have to get attachment_id, I don't have it.

What I have is only image url. I don't know whether I am missing it somewhere or not.


1 Answer 1


use this one and follow the structures

  $post_thumbnail_id = get_post_thumbnail_id( $post_id ); 
 $imgarr = wp_get_attachment_image_src($post_thumbnail_id,'medium'); 
 echo $imgarr[0];/*it will return image url in medium size*/
  • Please add some explanation of your code. Links to the Codex entries for those functions would be helpful too.
    – s_ha_dum
    Jun 11, 2013 at 13:58
  • k, Using the above said script(github) I have added a repeatable field group with a text box and a image upload button, using wordpress native media uploader i can upload image and I am storing uploaded images url inside the corresponding text box. So what I want is I want to access the other sizes of images That might have been created while I upload image using the wp native media uploader, imean thumbnails, or other sizes.to access images i am using <?php $images= get_post_meta($post->ID, 'repeatable_fields', true);?>,it returns an multidimensional array. so here i want to get smaller sizes
    – Salih K
    Jun 12, 2013 at 5:28
  • @s_ha_dum - plz see this question, this exactly i want to achieve - stackoverflow.com/questions/5487444/… - besides resizing and all, is there any possibility to get the wordpress cropped versions of images
    – Salih K
    Jun 12, 2013 at 6:19
  • @PradiptaSarkar : Edit your answer with that information please.
    – s_ha_dum
    Jun 12, 2013 at 13:44

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.