wordpress - Wordpress Gutenberg img 或画廊链接,如何从全尺寸更改为大尺寸
问题描述
在我的 wordpress 项目中,如果图像链接到媒体选项打开,我想将图像 url 大小从全尺寸更改为大格式。我试过这个过滤器,但不幸的是它不起作用......
function default_get_attachment_link_filter( $content, $post_id, $size, $permalink ) {
if (! $permalink) {
$image = wp_get_attachment_image_src( $post_id, 'large' );
$new_content = preg_replace('/href=\'(.*?)\'/', 'href=\'' . $image[0] . '\'', $content );
return $new_content;
}
}
add_filter('wp_get_attachment_link', 'default_get_attachment_link_filter', 10, 4);
任何帮助都非常感谢。谢谢
解决方案
推荐阅读
- json - 如何使用 pandas 读取 JSON 数据?
- stm32 - 通过 ESP8266 WiFi 使 STM32 上的 FatFS 文件系统可用于 PC
- xml - 在 XML 中添加带空格的行
- django - 是否可以使用 django orm 生成结果集的哈希?
- javascript - 以特定顺序将图像绘制到画布
- kotlin - 如何更改解析?
- phpstorm - 在 PhpStorm 中设置默认包含路径
- node.js - Angular 6 和 PWA
- python-3.x - 如何根据元素的频率对熊猫数据框进行颜色编码?
- google-apps-script - 谷歌数据工作室表显示日期列为空