Wordpress ThickBox 添加“查看原图”效果代码_javascript技巧
程序员文章站
2022-04-28 08:06:28
...
在 wp-includes/js/thickbox/thickbox.js 大概39行的function tb_show(caption, url, imageGroup)中,添加如下行(粗体红色字代表新添加的代码)
function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link
try {
/// 代码省略。。。
TB_NextHTML = "";
TB_imageCount = "";
TB_FoundURL = false;
////// 打开新窗口显示原图
TB_OpenNewHTML = "";
if(imageGroup){
/// 代码省略。。。
if (TB_FoundURL) {
TB_NextCaption = TB_TempArray[TB_Counter].title;
TB_NextURL = TB_TempArray[TB_Counter].href;
TB_NextHTML = " "+thickboxL10n.next+"";
} else {
TB_PrevCaption = TB_TempArray[TB_Counter].title;
TB_PrevURL = TB_TempArray[TB_Counter].href;
TB_PrevHTML = " "+thickboxL10n.prev+"";
}
////// 打开新窗口显示原图
TB_OpenNewHTML = " 查看原图";
} else {
TB_FoundURL = true;
TB_imageCount = thickboxL10n.image + ' ' + (TB_Counter + 1) + ' ' + thickboxL10n.of + ' ' + (TB_TempArray.length);
////// 打开新窗口显示原图
TB_OpenNewHTML = " 查看原图";
}
}
}
}
/// 代码省略。。。
// Resizing large images - orginal by Christian Montoya edited by me.
/// 代码省略。。。
// End Resizing
TB_WIDTH = imageWidth + 30;
TB_HEIGHT = imageHeight + 60;
//jQuery("#TB_window").append("" + " ");
/////// 显示下一张图 + 新窗口查看原图(添加TB_OpenNewHTML)
jQuery("#TB_window").append("" + " ");
jQuery("#TB_closeWindowButton").click(tb_remove);
if (!(TB_PrevHTML === "")) {
/// 代码省略。。。
效果:
点击“查看原图”后,将在浏览器新窗口(Tab)显示原图。
复制代码 代码如下:
function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link
try {
/// 代码省略。。。
TB_NextHTML = "";
TB_imageCount = "";
TB_FoundURL = false;
////// 打开新窗口显示原图
TB_OpenNewHTML = "";
if(imageGroup){
/// 代码省略。。。
if (TB_FoundURL) {
TB_NextCaption = TB_TempArray[TB_Counter].title;
TB_NextURL = TB_TempArray[TB_Counter].href;
TB_NextHTML = " "+thickboxL10n.next+"";
} else {
TB_PrevCaption = TB_TempArray[TB_Counter].title;
TB_PrevURL = TB_TempArray[TB_Counter].href;
TB_PrevHTML = " "+thickboxL10n.prev+"";
}
////// 打开新窗口显示原图
TB_OpenNewHTML = " 查看原图";
} else {
TB_FoundURL = true;
TB_imageCount = thickboxL10n.image + ' ' + (TB_Counter + 1) + ' ' + thickboxL10n.of + ' ' + (TB_TempArray.length);
////// 打开新窗口显示原图
TB_OpenNewHTML = " 查看原图";
}
}
}
}
/// 代码省略。。。
// Resizing large images - orginal by Christian Montoya edited by me.
/// 代码省略。。。
// End Resizing
TB_WIDTH = imageWidth + 30;
TB_HEIGHT = imageHeight + 60;
//jQuery("#TB_window").append("" + " ");
/////// 显示下一张图 + 新窗口查看原图(添加TB_OpenNewHTML)
jQuery("#TB_window").append("" + " ");
jQuery("#TB_closeWindowButton").click(tb_remove);
if (!(TB_PrevHTML === "")) {
/// 代码省略。。。
效果:
点击“查看原图”后,将在浏览器新窗口(Tab)显示原图。
上一篇: FLOW CHART与UI FLOW 有哪些不同点
下一篇: PHP正则匹配查看原图,该怎么解决