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.
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
/* * 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(); }
Then we just change where mediaSelect is called to reflect this. in inc/template.php edit the function tpl_mediafilelist:
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\')">';
–ian
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 661 to look like
//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'; }
This would make a good option to add into the core.
— 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