在我的WordPress主题得到最近发表图片,代码如何在WordPress中将图像裁剪为特定的宽度和高度以img src?
$gallery = get_post_meta($post->ID, 'property_gallery', true);
$images = explode("~~~", $gallery);
<img src="' . esc_url($images[1]) . '" alt="' . esc_attr($title) . '" />
的代码显示了近期楼市的图像,但问题是,我得到的图像是全分辨率。
我想裁剪图像为200x200或100x100。
您可以在全分辨率图像中看到最近列出的属性,这会导致页面加载问题。 http://dxboffplan.com/developers/
wp_get_attachment_image_src没有得到IMG,后实际上是没有特色的最近的文章中的图片,它是一个自定义后场输入其中i上传画廊图像的帖子。 –
@SajjadAhmad查看上面更新的答案。我在代码的最后一行提出了语法错误,希望你现在能得到结果。谢谢 –
感谢您的时间和精力,但不幸的是,仍img src是空的。但我有不同的方式。 现在我使用精选img我的代码是这样的: $ imgUrl = wp_get_attachment_image_src(get_post_thumbnail_id($ post-> ID),'thumbnail');