Add the "View Source image" effect code to WordPress ThickBox

Source: Internet
Author: User

Add the following lines to function tb_show (caption, url, imageGroup) of about 39 rows of wp-shortdes/js/thickbox. js (the bold red word indicates the newly added code) Copy codeThe Code is as follows: function tb_show (caption, url, imageGroup) {// function called when the user clicks on a thickbox link

Try {
/// The code is omitted...
TB_NextHTML = "";
TB_imageCount = "";
TB_FoundURL = false;
///// Open a new window to display the original image
TB_OpenNewHTML = "";

If (imageGroup ){
/// The code is omitted...
If (TB_FoundURL ){
TB_NextCaption = TB_TempArray [TB_Counter]. title;
TB_NextURL = TB_TempArray [TB_Counter]. href;
TB_NextHTML = "<span id = 'tb _ next'> <a href = '#'>" + thickboxL10n. next + "</a> </span> ";
} Else {
TB_PrevCaption = TB_TempArray [TB_Counter]. title;
TB_PrevURL = TB_TempArray [TB_Counter]. href;
TB_PrevHTML = "<span id = 'tb _ prev'> <a href = '#'>" + thickboxL10n. prev + "</a> </span> ";
}
///// Open a new window to display the original image
TB_OpenNewHTML = "<span style = 'font-size: 11pt '> <a href ='" + url + "'target = '_ blank' style = 'color: red'> view the source image </a> </span> ";

} Else {
TB_FoundURL = true;
TB_imageCount = thickboxL10n. image + ''+ (TB_Counter + 1) +'' + thickboxL10n. of + ''+ (TB_TempArray.length );
///// Open a new window to display the original image
TB_OpenNewHTML = "<span style = 'font-size: 11pt '> <a href ='" + url + "'target = '_ blank' style = 'color: red'> view the source image </a> </span> ";
}
}
}
}

/// The code is omitted...

// Resizing large images-orginal by Christian Montoya edited by me.

/// The code is omitted...
// End Resizing

TB_WIDTH = imageWidth + 30;
TB_HEIGHT = imageHeight + 60;
// JQuery ("# TB_window "). append ("<a href ='' id = 'tb _ imageoff' title = '"+ thickboxL10n. close + "'> </a> "+" <div id = 'tb _ caption '> "+ caption +" <div id = 'tb _ secondLine '> "+ TB_imageCount + TB_PrevHTML + TB_NextHTML +" </div> <div id = 'tb _ closewindow'> <a href =' # 'id = 'tb _ closeWindowButton 'title = '"+ thickboxL10n. close + "'> </a> </div> ");
////// Display the next image + view the original image in a new window (add TB_OpenNewHTML)
JQuery ("# TB_window "). append ("<a href ='' id = 'tb _ nextimage' title = '"+ thickboxL10n. next + "'> </a> "+" <div id = 'tb _ caption '> "+ caption +" <div id = 'tb _ secondLine '> "+ TB_imageCount + TB_PrevHTML + TB_NextHTML + TB_OpenNewHTML +" </div> <div id = 'tb _ closewindow'> <a href = '#' id = 'tb _ closeWindowButton 'title = '"+ thickboxL10n. close + "'> </a> </div> ");

JQuery ("# TB_closeWindowButton"). click (tb_remove );

If (! (TB_PrevHTML = "")){
/// The code is omitted...

Effect:

After you click "View Source image", the original image is displayed in the new browser window (Tab. Author: Elf Sundae)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.