Topic: open links and images in new window

hello i want to know how to make images and links open in new window not in the same window .

image: http://www.celebs-fashion.net/wp-content/plugins/wp-o-matic/cache/48128_th_82742_Britney_Spears.ROLLING_STONE.Issue_1067_December_11_2008.Scanned_by_KROQJOCK.UHQ1_122_806lo.jpg

link: google.com

thank u

Re: open links and images in new window

none have the solution ??

Re: open links and images in new window

Please change image!! big_smile

Re: open links and images in new window

why change the image, it's just a example,
and why u didn't give me the solution ...

where are you admin of this forum, because they are some people had the same problem of me , find us a solution

thank u

5 (edited by User33 2008-11-26 18:41)

Re: open links and images in new window

Replace Line 609 on 'include/parser.php' with:

        return '<a href="'.$full_url.'" target="_blank">'.$link.'</a>';

and Line 627:

    $img_tag = '<a href="'.$url.'" target="_blank">&lt;'.$lang_common['Image link'].'&gt;</a>';

Re: open links and images in new window

mixcelebs wrote:

why change the image, it's just a example,
and why u didn't give me the solution ...
where are you admin of this forum, because they are some people had the same problem of me , find us a solution
thank u

I Joke!

Re: open links and images in new window

Next time, use the SEARCH button on the site, if you had searched, you would of found the answer, even though the results are for 1.2 it still will show you what you need to edit to get it to work with 1.3.

Fact even the 1.2 tutorial works on 1.3, so you would of been able to get your answer which has been answered before if you search.
http://wiki.punres.org/Open_links_in_a_new_window

Sorry. Unactive due to personal life.

Re: open links and images in new window

thank you very much, i am new here that's why i didn't search in the site.

i joke too fantasma . thank u

Re: open links and images in new window

This is the patch for PunBB v1.2.20, authored by me (legolas558). It will use target="_blank" only on external URLs.

--- include/parser.php    2009-08-20 08:12:27.000000000 +0200
+++ include/parser.php    2009-08-20 08:11:07.000000000 +0200
@@ -277,7 +277,22 @@
     // Ok, not very pretty :-)
     $link = ($link == '' || $link == $url) ? ((strlen($url) > 55) ? substr($url, 0 , 39).' &hellip; '.substr($url, -10) : $url) : stripslashes($link);
 
-    return '<a href="'.$full_url.'">'.$link.'</a>';
+    return '<a href="'.$full_url.'"'.add_auto_target($full_url).'>'.$link.'</a>';
+}
+
+//
+// Automatically add target="_blank" for URLs not on this website
+//
+function add_auto_target($url) {
+    $p = strpos($url, '//');
+    if ($p !== false) {
+        $url = substr($url, $p+2);
+        $p = strpos($url, '/');
+        $url = substr($url, 0, $p);
+        if ($_SERVER["SERVER_NAME"] == $url)
+            return '';
+    }
+    return ' target="_blank" rel="nofollow"';
 }
 
 
@@ -288,7 +303,7 @@
 {
     global $lang_common, $pun_config, $pun_user;
 
-    $img_tag = '<a href="'.$url.'">&lt;'.$lang_common['Image link'].'&gt;</a>';
+    $img_tag = '<a href="'.$url.'"'.add_auto_target($url).'>&lt;'.$lang_common['Image link'].'&gt;</a>';
 
     if ($is_signature && $pun_user['show_img_sig'] != '0')
         $img_tag = '<img class="sigimage" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';

10

Re: open links and images in new window

Garciat wrote:

Replace Line 609 on 'include/parser.php' with:

        return '<a href="'.$full_url.'" target="_blank">'.$link.'</a>';

and Line 627:

    $img_tag = '<a href="'.$url.'" target="_blank">&lt;'.$lang_common['Image link'].'&gt;</a>';

Thanks a lot! I never thought I would find a solution.