DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:image_nolink

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tips:image_nolink [2008-12-10 01:01] – changed line number 89.246.167.21tips:image_nolink [2012-11-24 11:15] (current) – deprecated with new media manager flam
Line 1: Line 1:
-====== Change default behavior of inserted images so they don't link ====== 
- 
-For a few sites I created, the users don't ever remember to use the ?nolink syntax when adding images. Without "?nolink", an inserted image will default to link to its media page. For many users, this isn't desired.  
- 
- 
- 
-===== Method 1 ===== 
- 
-To make it the default when using the Media Selection page that inserted images have the ?nolink automatically appended, we can redefine the mediaSelect javascript function. It'll take an argument to determine if the media file type is an image, and if so, it'll add the "?nolink" text. 
- 
-in ''lib/scripts/script.js'' edit the function mediaSelect 
-<code javascript> /*  
- * Edited to accomodate a default where no images are linked 
- */ 
-function mediaSelect(file,image){ 
- if (image == 'yes') { 
-   opener.insertTags('wiki__text','{{'+file+'?nolink|','}}',file); 
-  } else { 
-   opener.insertTags('wiki__text','{{'+file+'|','}}',file);  
-  } 
-    window.close(); 
-} 
-</code> 
- 
-Then we just change where mediaSelect is called to reflect this. in ''inc/template.php'' edit the function tpl_mediafilelist: 
-<code php>    ptln('<li><div class="li">',4); 
- 
-    // added to remove image links by default 
-    if($item['isimg']){ 
-      // remove link from images 
-      ptln('<a href="javascript:mediaSelect(\':'.$item['id'].'\',\'yes\')"'.$class.'>'. 
-         utf8_decodeFN($item['file']). 
-         '</a>',6); 
-     } else { 
-         ptln('<a href="javascript:mediaSelect(\':'.$item['id'].'\',\'no\')"'.$class.'>'. 
-         utf8_decodeFN($item['file']). 
-         '</a>',6); 
-     } 
- 
-(...) 
- 
-      //edited to remove image links by default 
-      print '<a href="javascript:mediaSelect(\':'.$item['id'].'\',\'yes\')">'; 
-</code> 
- 
---[[ian@subcultured.org|ian]] 
- 
- 
- 
-===== Method 2 ===== 
- 
-If you already have an established site and wish to turn off image linking by default, make the following change:\\ 
-Open **inc/parser/handler.php** and change the block at line 686 to look like 
-<code php> 
-    //get linking command 
-    if(preg_match('/nolink/i',$param)){ 
-        $linking = 'nolink'; 
-    }else if(preg_match('/direct/i',$param)){ 
-        $linking = 'direct'; 
-    }else if(preg_match('/details/i',$param)){ 
-        $linking = 'details'; 
-    }else{ 
-        $linking = 'nolink'; 
-    } 
-</code> 
-This would make a good option to add into the core.\\ 
- --- //[[mezell1@ece.utk.edu|Matt Ezell]] 2007-02-11 21:56// 
- 
->IIRC, this will actually make **all** inserted media default to nolink, which may not be desirable (think PDF links, for example)  --[[ian@subcultured.org|ian]] 
  
tips/image_nolink.1228867265.txt.gz · Last modified: 2009-09-21 03:26 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki