gpt4 book ai didi

php - 用于帖子中图像的标准链接相关的 Wordpress 函数

转载 作者:行者123 更新时间:2023-11-30 06:47:31 24 4
gpt4 key购买 nike

我正在使用 colorbox 在我的 wordpress 网站上查看更大的图像。为此,我必须将图像插入帖子,关闭 wordpress 媒体弹出窗口,单击图像,单击“编辑图像”图标,进入高级设置并在选项下添加“附件”字段“链接相对”。

现在缩略图通过链接 rel="attachment"连接到灯箱。许多不必要的步骤,对普通用户来说也是高级的。

有人知道在帖子中添加图片时自动添加链接 rel="attachment"的解决方案吗?其他解决方案也很受欢迎。

在此处查看缩略图和标记:http://pokerstrategy.org.uk/news/2011-pca-main-event-final-table-determined

用于颜色框的 JS:$("a[rel='attachment']").colorbox();

最佳答案

也许您可以向 the_content 添加一个过滤器而不是 jQuery,这样当 Wordpress 加载帖子时它会自动执行而不是使用 jQuery?我在想这样的事情:

add_filter( 'the_content', 'lightboxfix');

function lightboxfix ($content) {
$content = preg_replace("/<img/","<img rel=\"attachment\"",$content,1);
return $content;
}

基本上,它抓取帖子内容,更改所有 <img..元素有 <img rel="attachment".. .我会试一试。

关于php - 用于帖子中图像的标准链接相关的 Wordpress 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4967146/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com