wp\u获取\u附件\u图像\u url wordpress

wp\u获取\u附件\u图像\u url wordpress,wordpress,Wordpress,我想得到一个图像大小640x640和使用wp_获取_附件_图像_url功能。 实际上,这种大小的图像在内容上传中不可用。如何获得最大接近值640x640的图像?基本上,您可以在该函数的官方文档中找到答案和非常好的示例: 小结: add_image_size( 'image-size-640', 640, 640, true ); //resize, crop in functions.php $img_id = 6; //need to get it dynamically $cropped

我想得到一个图像大小640x640和使用wp_获取_附件_图像_url功能。
实际上,这种大小的图像在内容上传中不可用。如何获得最大接近值640x640的图像?

基本上,您可以在该函数的官方文档中找到答案和非常好的示例:

小结:

add_image_size( 'image-size-640', 640, 640, true ); //resize, crop in functions.php

$img_id = 6; //need to get it dynamically

$cropped_image = wp_get_attachment_image_url( $img_id, 'image-size-640' ); //use custom set size
添加新尺寸后,WordPress必须重新生成图像。最佳插件: