老问题了,但我想我应该分享我的解决方案,它通过为post\\u thumbnail\\u html添加一个过滤器,使所有图像都有响应。
add_filter(\'post_thumbnail_html\', \'slug_responsive_img\', 5, 5);
//Image sizes for Interchange
add_image_size( \'fd-lrg\', 1024, 99999);
add_image_size( \'fd-med\', 768, 99999);
add_image_size( \'fd-sm\', 320, 9999);
function slug_responsive_img($html, $post_id, $post_thumbnail_id, $size, $attr) {
//make image links
$attachment_id = $post_thumbnail_id;
$default = wp_get_attachment_image_src($attachment_id);
$size = \'fd-sm\';
$small = wp_get_attachment_image_src($attachment_id, $size);
$size = \'fd-med\';
$med = wp_get_attachment_image_src($attachment_id, $size);
$size = \'fd-lrg\';
$lrg = wp_get_attachment_image_src($attachment_id, $size);
//create image tag with queries
$html = \'<img src="\'.$default[0].\'"\';
$html .= \'data-interchange="[\'.$default[0].\', (default)],\';
$html .= \'[\'.$small[0].\', (only screen and (min-width: 320px))],\';
$html .= \'[\'.$med[0].\', (only screen and (min-width: 768px))],\';
$html .= \'[\'.$lrg[0].\', (only screen and (min-width: 1024px))],\';
$html .=\'">\';
return $html;
}