下面是我如何调用wp\\u get\\u attachment\\u image的:
$id = attachment_url_to_postid( get_theme_mod( \'blue_logo\' ));
echo wp_get_attachment_image($id, $size = \'blue_logo\', $icon = false, array(
"class" => "blue_logo"
))
“blue\\u徽标”大小是指我在函数中创建的图像大小。php。下面是输出元素的外观。
<img width="216" height="67" src="http://34.219.141.113/wp-
content/uploads/2022/02/Q7_WHM_HOR_BLUE-1.jpg" class="blue_logo" alt="" loading="lazy"
srcset="http://34.219.141.113/wp-content/uploads/2022/02/Q7_WHM_HOR_BLUE-1.jpg 2062w,
http://34.219.141.113/wp-content/uploads/2022/02/Q7_WHM_HOR_BLUE-1-300x93.jpg 300w,
http://34.219.141.113/wp-content/uploads/2022/02/Q7_WHM_HOR_BLUE-1-1024x317.jpg 1024w,
http://34.219.141.113/wp-content/uploads/2022/02/Q7_WHM_HOR_BLUE-1-768x238.jpg 768w,
http://34.219.141.113/wp-content/uploads/2022/02/Q7_WHM_HOR_BLUE-1-1536x476.jpg 1536w,
http://34.219.141.113/wp-content/uploads/2022/02/Q7_WHM_HOR_BLUE-1-2048x635.jpg 2048w,
http://34.219.141.113/wp-content/uploads/2022/02/Q7_WHM_HOR_BLUE-1-1568x486.jpg 1568w" sizes="
(max-width: 216px) 100vw, 216px" style="width:100%;height:30.99%;max-width:2062px;">
我知道我可以用CSS覆盖样式,但当我这样做时,会导致一些压缩,从而导致图像质量下降。有可能一开始就没有内联样式吗?我在这里的最终目标是能够显示通过自定义WP\\u Customize\\u image\\u控件上载的图像,并在尽可能少的图像压缩/质量损失的情况下设置图像大小。
谢谢你的帮助!