admin管理员组

文章数量:1122826

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.

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.

Share Improve this question edited Feb 5, 2019 at 11:07 Krzysiek Dróżdż 25.5k9 gold badges53 silver badges74 bronze badges asked Jun 10, 2013 at 13:43 Salih KSalih K 1331 silver badge8 bronze badges 2
  • Post your code please. – s_ha_dum Commented Jun 10, 2013 at 14:57
  • @s_ha_dum : m using this code to get repeating fields - gist.github.com/helenhousandi/1593065 – Salih K Commented Jun 11, 2013 at 4:16
Add a comment  | 

1 Answer 1

Reset to default 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*/

本文标签: customizationGet a different size of Image thumbnail while working with custom metabox