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
1 Answer
Reset to default 1use 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
版权声明:本文标题:customization - Get a different size of Image thumbnail while working with custom metabox 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736310066a1934244.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论